activities , active and passive classes in software engineering [closed] - uml

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
you might know that we have 2 kinds of classes based on activities , passive class and active class.
I just know that active class is a class which needs to use from all of the CPU like web services or windows while loading.
can u help me about passive class with some examples about it.

An active class is one where an instance of the class starts its behaviour as soon as it is created. This behaviour is typically specified using activities or state machine. The behaviour terminates when the instance is destroyed.
A passive class has behaviour that is defined by its operations. This behaviour only starts when one of the operation is called on an instance of that class. The behaviour terminates once the operation returns.

The great majority of classes that you will design are passive. This means that they get instantiated, their methods get called, and they perform the operations defined in their methods. In effect, they do what they do when they are asked to, by another object calling one of their methods.
Active objects, on the other hand, do what they do as a consequence of being created. Implementation typically has a private method that gets called in the object's constructor in some way.
A simple and visual example of an active object is this (borrowed from here). Suppose you want to simulate rain falling down a screen. Each raindrop is simply a ball falling from the top of the screen to the bottom. So you have an active class called Drop, which draws a filled circle at a random x coordinate at the top of the screen, and moves it in increments to the bottom. (Again, this behavior occurs by calling a private method in the constructor.) A RainMaker class simply instantiates Drop classes, perhaps at random intervals of time.
The Drop class is active because it doesn't need to be told to fall from the top of the screen to the bottom. It does that by the fact of having been instantiated.
Most examples are more complex, because most active objects need to interact with other objects during their lifetime to do anything useful (and these Drop objects don't). An indicator of an active object is that it controls when it executes operations it's asked to execute. So, asynchronous messaging queues and that sort of thing are indicators.
This gives some more advanced information.

Related

How to model a simple Workout app (Class diagram) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I've developed a simple Workout Android app without uml class diagram in mind. Now I want to refactor it.
How the app works
On the home screen, there's just a button to start an workout session. By clicking on it, a countdown of 10 seconds is fired, waiting for the person to get ready.
Then, the app will display several exercises, one at a time, with a break interval between them. Each exercise takes 30 seconds; and each break interval, 10 seconds. On each exercise/break, the app shows the following information:
A countdown timer of the current exercise/break;
The name of the current exercise or, in the case of a break interval, the name of the next exercise;
An image that illustrates the current (or the next) exercise;
A pause button.
Finally, when the workout session finishes, the app shows a GIF as a celebration. On this last screen there's also a "Go home" button.
The UML class diagram
I've made the following UML class diagram to model this app:
My doubts
However, I'm not so sure if this is the proper way to model the scenario described. I'd appreciate if I could get some feedback/review about it.
One of the main things that I'm in doubt of has to deal with the WorkoutActivity class. It has no attributes in the diagram because I couldn't think of any attribute for it in the way that I'm modeling this problem. And because it's empty, it's a little weird to me. I thought about using a list class (e.g. ExercisesList) to model the set of exercises, but I'm kind of stuck with this diagram.
Another issue is about the buttons, should I include them in the diagram?
It all depends on what you want to represent.
If your model is meant for the domain of workouts, keep it simple: the buttons (the user interface objects) and the timer (execution context) would not be needed.
In the narrative you mentioned a "workout session". I assume that this is what the WorkoutActivity is about. So better be consistent with the naming.
You can think easily of attributes: it’s the date and time (and user account?) of the session: this could allow the user to follow his/her regularity in the training.
A more general approach would be to have a WorkoutSession composed of several abstract WorkoutActivity (caution: different meaning than in your current diagram). Each WorkoutActivity would be a specialisation: either an Exercise, a BreakInterval or a InfoActivity (e.g. FinalActivity, but why not also a StartActivity activity to encourage new users, and other occasional activities such as tips&tricks, or advertisement). Something like:
The constraint of having one break after each exercise does not need to be structural: it can be a constraint that you enforce when the session is composed or generated. This gives you more flexibility, if in the future you’d line to have a break every 2 or 3 exercises (e.g.:advanced users).

How do I decide the attributes and operations that a class will be responsible for in a design class diagram? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to create a design class diagram based on the use case below:
Preconditions: User is logged in
The system presents the list of expense claims that have been authorised for payment.
The user selects an expense claim from the list.
The system shows all the items recorded under it.
The user selects one of two options: (a) to confirm the claim for payment, or (b) to review
it further.
IF option (a) is selected THEN
5.1 The system records the confirmation of payment and notifies the accounts
department.
ELSE
5.2 DO EXTEND Review Claim
END IF
How do I decide which class (between account and system) is responsible for which attributes and operations? Do I decide based on my own interpretation or is there an established method?
This is what I have so far: design class diagram
Designing a class diagram is usually something that is open to the interpretation of the person making it. Not sure about other methods of going about this, but this is how I usually approach this problem:
Identify the types of objects (i.e. classes) that exist within the scenario. These are individual items that exist within your scenario (e.g. User, ExpenseClaim, ExpenseItem). A good practice for identifying these are items that usually have pieces of data (i.e. properties) or perform a function (i.e. methods). In general, you may want to err on the side of identifying as many things as possible as the idea is that each class is supposed to do a specific thing and no more than that (you will probably revise this when carrying out the later steps). However, don't confuse objects with actors - the system is actually what the whole class diagram explains so it should never be considered as a class.
For each type of object, look at the data they contain and translate them into either properties or relations onto other types of object. Really try and limit the amount of data that each object has; if one object has a lot of properties, it is probably ripe for splitting it up into multiple objects. Taking the example of ExpenseClaim and ExpenseItem, its clear that each ExpenseClaim has a list of ExpenseItem, so you might want to link these with a composition arrow.
Now lastly look at each one and think about the things that other objects might try and do to change the data that the object has - this will probably be your methods. For an ExpenseClaim object it will probably have a confirm() method for changing the state of an isConfirmed::boolean property. Again, really try and limit the amount of functionality to the specific role that the object plays - if an object has too many functions or a function that doesn't really suit it, it probably means that there is another (new) object that will suit it better.

State Machines - Can you model alternatives flows? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am trying to implement a state machine, however I am very confused about it at the moment.
Can you have states that model alternative flows, such as Vehicles not existing - if a penalty fine is to be issued, or a Reg no being invalid?
I understand your problem - state machine has no easily visible fork element in VP UMP . But it needn't. Every state block works as multi-fork. All arrows from a state to other ones are cases, "what changes if..." The text of condition is on the arrow. An arrow can have more, than one condition.
So, the answer is
YES!
And really you can use forks, too. They are hidden under "initial pseudo state". But use them only if there is one event coming from a state and it is forking without the relation to a state. Or if it starts some flow.
I can't commment yet, therefore feedback to your question is not possible for me in another way than answer. My answer'd depend on your problem
If you're thinking in flows maybe you should use an activity diagram instead of a state machine, there's a difference between the functional und the behavioural view.
Rethink the states you use
Use a hierarchical state machine (e.g. have a look in http://www.barrgroup.com/Embedded-Systems/How-To/Introduction-Hierarchical-State-Machines)
There are alternative flows and paralel execution possible in state machines of course. Use Shoice pseudstate to define alternative transitions. Condition to decide outging transition is defined as a guard of transition. States must reside in the same region. For concurrent states activation, use Fork pseudostate. Transitions outgoing from fork pseudostate must be directed to the states, all in differen regions.

How are Boundary, Entity and Control classes defined? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm referencing a book by bennet, s et al (2002). Object-orientated systems analysis and design 2nd ed. McgraawHill:Maidenhead.
In the book when describing requirements analysis Bennet refers to three types of 'analysis class stereotypes' as a way of breaking down use case diagrams into defined classes.
The first two seem fairly straight forward : an boundary class is the terminus between the user and the system, or the system and other systems that it relies on. An entity class is the 'information and associated behaviour of some phenomenon or concepts such as an individual, a real life object, or a real life event' i.e. the data that you're trying to model or store, such as a person.
Finally, there are control classes which 'represent co-ordination sequencing, transactions and control of other objects'. This definition isn't as clear as Bennet states:
"meanwhile, the boundary class represents interaction with the user and the entity clases
represent the behaviour of things in the application domain and storage of information that
is directly associated with these things"
This rather begs the question what exactly is an application or software domain in this context? How does the control class fit in with these other two definitions?
I think this offers a best case solution :
http://epf.eclipse.org/wikis/openuppt/openup%5Fbasic/guidances/concepts/entity%5Fcontrol%5Fboundary%5Fpattern,%5FuF-QYEAhEdq%5FUJTvM1DM2Q.html
Entity objects represent the persistent information tracked by the system.
Boundary objects represent the interactions between the actors and the system.
Control objects are in charge of realizing use cases.
Modeling the system with entity, boundary, and control objects provides developers with simple heuristics to distinguish different, but related concepts.

Help understanding the Single Responsibility Principle [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm trying to understand what a responsibility actually is so I want to use an example of something I'm currently working on. I have a app that imports product information from one system to another system. The user of the apps gets to choose various settings for which product fields in one system that want to use in the other system.
So I have a class, say ProductImporter and it's responsibility is to import products. This class is large, probably too large.
The methods in this class are complex and would be for example, getDescription. This method doesn't simply grab a description from the other system but sets a product description based on various settings set by the user. If I were to add a setting and a new way to get a description, this class could change.
So, is that two responsibilities? Is there one that imports products and one that gets a description. It would seem this way, almost every method I have would be in it's own class and that seems like overkill.
I really need a good description of this principle because it's hard for me to completely understand. I don't want needless complexity.
The 'responsibility' is defined in this principle as a reason to change. In this case the single responsibility of your class would be to import products. If the way of importing product changes, then the class should change.
The intention is to avoid having different things changing the same class at the same time. For example if your product importer class also defined its output format, it would then have two responsibilities, as likely the output format is totally unrelated to the mechanism of importing the data.
Now, that the class is huge and that getDescription() also sets a description are not a direct violation of the SRP, but of different principles. Namely, that you should avoid having huge classes (shows a lack of design) and each method should do a single thing (which would be kind of a more concrete version of the SRP.)

Resources