Let's say I am making a Use Case about filling a quiz. You have only 5 minutes to fill that quiz. When doing the Use Case for "Filling the Quiz", how should I signal there is a time limit and that after that the Use Case is finished? I simply write it by text or is there anything more formal to use?
Sketch of what my Use Case can be:
1. The Actor tells the System he's ready to start the quiz.
2. The System presents the Actor with the first question of the Quiz and its 4 possible answers and tells him how much time he has left.
3. The Actor tells the System what is his chosen answer (a number between 1 and 4).
Repeat steps 2-3 until there are no questions left.
4. The System registers the results of the quiz.
I could just put operations between all those shown above to check whenever the time left is over, but there is probably a better way to show this.
Thanks
You can use an alternative flow timeout case, like
Alternative Flow 1: Timeout
2. The System detects that ...
To be a bit more precise, but agree with the other answer in general, for this situations Alistair Cockburn (Writing effective Use Cases) recommends using extending use cases (alternate flows), which would have in their extension points the time limit. In textual form, you can easily use the range of numbers of lines of scenario lines, where the timeout can happen.
Related
I want to check what is the definition of «iterative» in expansion regions in activity diagrams. For me personally this was never a question because I understand it as letting me do a For loop, e.g.,
For i=1 to 10
Do-Something // So it does it 10 times
End For
However, while I was presenting my UML diagram to an audience, an engineer team leader (not a UML maven) objected against the term ‘iterative’, because he understood ‘iterative’ to mean an 'iterative process' such that each step improves a result. I am also aware of this definition, but I assume the UML definition is not that, but rather means a simple For-Loop.
Please confirm that the UML definition of «iterative» and iteration is like a simple For-loop. Or otherwise, if so.
No, it has a different meaning. UML 2.5 states in p. 480:
The mode of an ExpansionRegion controls how its expansion executions proceed.
If the value is iterative, the expansion executions must occur in an iterative sequence, with one completing before another can begin. The first expansion execution begins immediately when the ExpansionRegion starts executing, with subsequent executions starting when the previous execution is completed. If the input collections are ordered, then the expansion executions are sequenced in the order induced by the input collection. Otherwise, the order of the expansion executions is not defined.
Other values for this keyword are parallel and stream. You can guess that behavior defined in a parallel region can be executed in parallel. stream is a bit more complicated and you might read on that page in the UML spec.
The for-loop itself comes from the input collection you pass to the region. This can be processed in either of the above ways.
tl;dr
So rather than a for loop the keyword «iterative» for the region tells that it's behavior may not be handeled in parallel.
Ahhh, semantics...
First a disclaimer - I am not a native English speaker. Yet my believe both my level of English and IT experience are sufficient to answer this question.
Let's have a look at the dictionary definition of iterative first:
iterative adjective
/ˈɪtərətɪv/
/ˈɪtəreɪtɪv/, /ˈɪtərətɪv/
(of a process) that involves repeating a process or set of instructions again and again, each time applying it to the result of the previous stage
We used an iterative process of refinement and modification.
an iterative procedure/method/approach
The highlight with a script font is mine.
Of course this is a pure word definition, not in the context of software development.
In real life a process can quite easily be considered repetitive but in itself not really iterative. Imagine an assembly line in a mass production factory. On one of the positions a particular screw/set of screws is applied to join two or more elements. For every next run, identical set of elements the same type and number of screws is applied. There is a virtually endless stream of similar part sets, each set consisting of the same type of parts as previously and requiring the same kind of connection. From the position perspective joining the elements is a repetitive process but it is not iterative, as each join is applied to a different set of elements - it does not apply to those already joined.
If you think of a code, it's somewhat different though. When applying a loop, almost always you have some sort of a resulting set impacted by it and one can argue that with every loop step that resulting set is being further changed, meaning the next loop step is applied on the result of the previous step. From this perspective almost every loop is iterative.
On the other hand, you can have a loop like that:
loop
wait 10
while buffer is empty
read buffer
You can clearly say it is a loop and nothing is being changed. All the code does is waiting for a buffer to fill. So it is not iterative.
For UML specifically though the precise meaning is included in qwerty_so's answer so I will not repeat it here.
I am learning operating systems through an online course and I came across some software solutions for Process Synchronization. The teacher is explaining all software solutions starting from using a single turn variable upto Peterson's solution.
I have a doubt in the most basic approach. Please refer to the attached screenshot from the course video for clarity. The approach is to use a single turn variable in case of two processes and store 1 or 2 in turn depending on which process wants to access the critical section. This approach guarantees mutual exclusion but does not satisfy the progress requirement because if turn is 1 initially and P2 wants to enter the critical section first then it will be simply blocked waiting in the while loop even though P1 is not in the critical section. My idea is to initiate turn as -1 and now proceed. No process will be blocked depending on other then.
I have checked multiple online courses but no one is discussing this simple change and rather moving on to advanced solutions like Petersons algorithm or semaphores. Am I thinking right? Is my approach correct?
What you're describing here is called "strict alternation". Your proposal to modify the algorithm so that turn is initially -1 won't work. In your example, if turn is not equal to 2, then process 1 will not block. If turn is not equal to 1, then process 2 will not block. Initially, if turn is -1, then neither process 1 nor process 2 will block. As a result, both can execute their critical sections at the same time. You no longer have the mutual exclusion property.
I'm working on building a simple API to consume data sent from small network-connected sensors/devices (think arduino, raspberry pi, etc). I want to log a reasonably accurate timestamp of when an event occurred on this remote device. Due to potential connectivity issues, the event might not always get sent back to the server right away. I don't want to rely on synchronizing a clock on the device if I can avoid it, so I'm going to try sending back a parameter that just contains the number of seconds since the event occurred. So, for example, an event is detected on the device, but for some reason it gets sent to the server 5 seconds later. The data would include a number "5" signifying that this happened 5 seconds ago based on the device's internal clock. The server then would take it's own clock-time, and subtract 5 seconds to generate the timestamp.
I'd like to come up with a parameter name that describes this time span that makes sense. Some options may include:
TimeSince
TimeAgo
DurationSince
However since this is a simple numeric field, I want the name to include the unit of measure for extra clarity, such as:
SecondsSince
SecondsAgo
TimeAgoSeconds
Has anyone come across common and/or sensible naming conventions for this kind of thing? Time since an event, and additionally, where and how to indicate units in a parameter name? None of my naming ideas really feel "right" but perhaps some discussion here might help identify one approach as being better than another.
Thanks.
My feeling is that ElapsedSeconds sounds reasonable.
Now, are you buffering those events? If they are meant to happening "every n seconds", how do you handle a missed value? I mean, you can buffer for n events, if they are not transmitted than you probably would overwrite the first of those n. When you transmit all your buffer how do you account for the missing one? Depending on the application it would be interest to fill a NaN for the event on that moment.
Does this make sense?
I am using AVR controller atmega328.
I need to check the status of two bits. I have two approaches, but not sure which one is most efficient. In first case in the code below, I am reading the port using PIND command twice (Two times PIND access is made). So is this an issue or I have to go with second if statement?
#define SW1 2
#define SW2 5
//check if both are high
if((PIND&(1<<SW1))&&(PIND&(1<<SW2)))
//Or
if((PIND&((1<<SW1)|(1<<SW2)))==((1<<SW1)|(1<<SW2)))
I suppose PIND is a peripheral register (what do you mean by "command"?).
The first check will read it once or twice, depending on the first comparison. This might generate a glitch, if SW1 changes between the first and second read.
Presuming SW? are switches: In general, it is better to read such a register once (possibly to a variable) and test for the bits. That ensures you get a snapshot of all input bits at the same time.
Also, the seconde version is not necessarily slower, as it safes a branch (IIRC AVR has no conditional instructions other than branch/jump).
The first reads PIND twice so is less efficient and a potential for error - the time between reads may be significant if interrupts or thread context switches intervene.
The second evaluates (1<<SW1)|(1<<SW2) twice, but in this case it is a compile time constant, so should have no impact on performance. But to be honest you are probably sweating the small stuff worrying too much about the code at this level. If you really need to know; take a look at the code the compiler generates (in the debugger disassembly or by getting the compiler to output an assembly listing), but it will take a long time to write code if you intend to second guess every line like this,
Its hard to say which of the above 2 will be more efficient without the output of assembler. However i would guess that the difference in performance would be very little.
In case 2 you are avoiding reading the registers twice but you are performing 2 additional operations.
If i were to make a guess i would say that option 1 would most likely to be faster since PIND is a AVR regsiter and the cost of reading would be less.
Having said that i would suggest using the first option as its more readable even its not found to be faster than option 2.
This is my first time I need to create a cutscene system. I have read a lot on the web about different ways to accomplish this task and have mixed them with my own ideas. Now, it is implementation time, but I need some info from other people with more experience than me in this field. Here we go:
1) Some years ago, I implemented a system that actions could be queued in a serial/parallel way, building a tree of actions that when executed created the final result. This can be sure used as the cutscene system director, but, wouldn't it be so much simple to just have a timeline with actions ran at a certain time? An example:
playMp3(0, "Song.mp3)
createObject(0, "Ogre", "Ogre1")
moveObject(1, "Ogre1", Vector3(100,100,1))
This way everything would be really simple to script. Serial actions are supported buy spreading them correctly in time and parallel actions just need to have shared time ranges.
One problem I have seen is that an action like Sync() (This just waits for all actions to finish before start the other that come afterwards) can't be used because we're using absolute time to trigger our actions. Anyway, a solution could be to have our actions layered based on last "sync()". I mean something like this:
playMp3(0, "Song.mp3)
createObject(0, "Ogre", "Ogre1")
moveObject(1, "Ogre1", Vector3(100,100,1))
sync()
moveObject(0,....);
createObject(1,....);
As you may notice, times after sync() starts again from 0, so, when a sync() is ran, and it determines all previous actions from last sync() are finished, timeLine elapsed time would be 0 again. This can be seen as Little cutscene action groups.
2) The previous explanation needs all actions to be added at the beginning of the cutscene playing. Is this how it usually is done? Or do you usually add actions to the timeline as they are needed?
Well, I could be wrong here, but I think this could be a nice & simple way to lay the actions for a cutscene. What do you think?.
Thanks in advance.
I've done a few of these systems. I'll tell you what I like to use I hope this will answer your questions.
One of the first cutscenes system I did used LISP dialect because it is just couple of hours work to get a parser working. It used to be something like...
(play "song1.mp3")
(set "ogre1" (create "ogre"))
(moveTo "ogre1" '(100, 100, 100))
(wait 1)
I created something like virtual machine (VM) that was processing my scripts. The VM didn't use separate thread instead it had update function that was executing X amount of instructions or until it hits some synchronization instruction like wait for 1 sec.
At that time this system had to work on J2ME device which didn't have XML parser and XML parser was too much code to add. These days I'm using XML for everything except sounds and textures.
These days I'm using keyframe systems as BRPocock suggested. The problem is that this will be harder to manage without proper tools. If you using already some 3D software for your models I'll suggest you to investigate the option to use that product. I use Blender for cutscenes for personal projects since it's free at my work place we use Maya and 3ds Max, but the idea is the same. I export to COLLADA and then I have my animation tracks with keyframes. The problem is that COLLADA format is not the simplest it is made to be flexible and require decent amount of work to extract what you need from it.
The problem you will have with your format is to describe the interpolation so you want to move the ogre from one position to another... how long is this going to take? The advantage of keyframe system is that you can specify the position of the ogre in time... but scripting for such system without a tool will be difficult. Still here is a simple suggestion for format:
(play 'song1.mp3')
(entity 'ogre'
(position (
0 (100 100 100)
2 (100 200 100)
5 (100 300 100)
7 (100 300 400)
8 (100 300 500))
(mood (
0 'happy'
7 'angry'))
(... more tracks for that entity if you need ...))
(entity 'human'
(position (.....)))
Now with format like this you can see at what time where the ogre has to be. So if you have time 1.5 sec in the cutscene you can interpolate between the keyframes with time 0 and 2 sec. Where mood can be something you don't interpolate just swich when the right tome comes. I think this format is going to be more flexible and will solve your sync issues but I wouldn't suggest you writing it by hand without tools for big scripts. If your cutscenes are going to be just few sec with a few entities then it may be good for your.