What is the use of control classes? - uml

I am trying to understand how to classify the classes as boundary/control/entity classes. I can understand boundary and entity classes although my understanding may not beperfect. Boundary is the classes which interacts with the user. So the classes used for the userinterface will be boundary classes. Entity class handles data. So entities I use in the ER diagram will be entity classes. But I understand nothing why control object is used. It is said that control object is used to encapsulate domain functionalities. What if the control classes are not used. Can you please explain me with example.I found some explaination but I am still confused.Why boundary should not interact directly with entity? There are also classes which are not boundary/control/entity. What are they?

Background
The Entity/Boundary/Control approach was introduced by Ivar Jacobson in 1992 as part of his use case driven Objectory development method.
At that time Jacobson used the terminology Entity/Interface/Control. The strange circle notation that you can find in relaction with ECB was already used in his books in 1992 and in 1994. By the way, the use case of his methods were integrated into UML and his development process was merged into RUP, when Rational acquired Objectory.
The idea behind his method was to adopt a very logic and formal and deductive analysis and design approach. It starts with identifying the systems behavioral requirement with use cases. Each link of use case to the outside world would then be represented as an interface object responsible for encapsulating completely the user interface.
Each use case would be represented as one or several control objects:
Control object: An object that encapsulates functionality of one or
several use cases - I.Jacobson in The Object Advantage, ACM Press, 1994
Finally the business objects managed by the system can be partly inferred from the use cases, and during the analysis.
Additional information
The fundaments of the Iconix process were introduced in 1999 as part of the book "Use Case Driven Object Modeling with UML" by Rosenberg & Stephen. Some additional robustness constraints were introduced, certainly to improve separation of concerns. For example, the direct link between entity and boundary is prohibited. Everything has to be channelled through control objects:
Control objects (which we usually call controllers because they often
aren't real objects), serve as the "glue" between boundary objects and
entity objects - D.Rosenberg, in the linked DDJ article.
They add a recommendation to clarify the intent :
Both boundary objects and entity objects are nouns, and controllers
are verbs.
Conclusion
So the principle is that the control object represents the business logic offered by use cases, interacting on one side with the boundaries, and on the other side with the entities. Control objects can't be invoked/accessed directly by the outside world.
If you would want to avoid the control objects, you would have a boundary objects with methods corresponding to the verbs/functions/use-cases that your system is supposed to provide. This wouldn't be according to the modern ECB, but perfectly valid according to Jacobson's original approach. Nevertheless your boundary would no longer comply with the single responsibility principle of a SOLID design.

Boundary interact with actors (e.g. users).
Entity classes represent data.
Control mediates between the boundary and the entities (e.g. executes an operation on the entities)
Source: http://www.cs.sjsu.edu/~pearce/modules/patterns/enterprise/ecb/ecb.htm

The control classes contain the business logic. It's the most important part of a system. While the boundary just controls whether the text is green or blue (very basically) and the entities control whether data is stored in text files or databases (also very basically) the control classes do all the business logic. What to change in the entity when the boundary send mouse/keyboard events an vice verse what to show from the entities in the boundary.

Related

Is it possible to join 2 controller classes to 1 boundary class?

I'm doing a college project where I'm required to create a class diagram to a school registration system. There I have included a Student class, a registrationUI Boundary Class and a registrationController controller class:
I have created a separate controller class called systemController to do the other tasks such as calculate bill, etc...
I'm asking if it's possible to join the systemController class with the registrationUI class.
ECB architectural pattern
It can be useful to realize that the ECB architecture pattern originates from the use case models:
a controller represent a use case (e.g. RegistrationControler for use case "Register Student"). A controller is linked to all the entites that are involved in the use case (can be several, e.g. Registration, Student and Course)
boundaries connect the use case with the involved external actors (e.g. RegistrationUI offers the user interface to the registration manager, or to a student if it's a self service system). So several boundaries can be linked to a controler (for example if a secondary actor is involved such as a third party system).
entities represent domain objects (e.g. Student). So an entity can be linked to several other related entities (e.g. Registration record for the Student in a Course)
Consistency check
At the bottom of this article or that article you'll see a short matrix showing the possible relations between entities, controls and boundaries.
According to this logic, entities [should never be directly connected to a boundary. So your Access relation between Student and RegistrationUI is not a good idea (ECB is not MVC).
One boundary and two controllers ?
If you follow Jacobson's OOSE logic of decomposing a use case into boundaries and controllers, or if applying a basic step by step robustness analysis in a use case driven modeling approach, you'd identify the controllers (use cases) and create a boundary for each link between an actor and the use case. So at first sight, one could think that a boundary can be linked to at most one controller.
But you there are also "included" use cases or "extended" use cases. These are not connected directly to an actor, at least not explicitly in the graphic. This means that you could very well have one boundaries related to several controllers. In this tutorial you have a very nice ATM example with one boundary and several ATM transactions. In the DDJ article link above, you also have a similar example.
P.S.: Personally, I'm not quite sure what you want to achieve with the systemController. I suggest that you think about its role and its name. Looking at it's content, I could imagine that it's a part of the RegistrationController. Bt I could also imagine that it's a dispatcher launching the other controllers.

What class name should I use for a class use to CRUD with some data type in nodejs

In many case, I need write a lot of class work with CRUD for some class. For example CRUD with pure object User, Book, Tag.
I usually make a directory named models, put all the CRUD classed into the models folder.
But I feel that the word model is not show essence. Is the word model well-defined in computer science? It means the pure object of User, or the means of CRUD of User?
I also use another name services for more complex logic, For example UserService may require other models than UserModel. But the word service is often conflict with some other case like an online service, backend service.
Are there any good names for the model and service in my case? BTW, I am most using Node.js; it may not conflict with the general conventions used in Node.js.
Ultimately, it will come down to what makes the code the most understandable both to you and to someone down the road who may have occasion to work on your code. If 'model' and 'services' convey the thought of what lies within in an obvious way to anyone coming in to the code, then they are probably fine. As far as standards, I don't know if there is a 'defined' set of names you have to use. In MVC, for example, you will use 'Models' as one of your folders in order to store all of the actual models you will be feeding your views, and this is understood in the MVC architecture that those names (Models, Views, Controllers) are the standard.
I agree with you that Model is a little ambiguous. Sometimes it is used to indicate domain objects such as User/Book/Tag, but sometimes it is used to indicate objects that deal with business logic, such as "Buying a book","Authenticating a user".
What's common to both uses is that "Model" is clearly separated from UI, that is handled entirely by the Views and the Controllers.
Another useful name is Entities. In Robert Martin's work on Object Oriented Design, he speaks of use-case-driven design, and distinguishes between three kinds of objects: Entity Objects, Interactor objects and Boundary objects.
Entity objects are useful in multiple use-cases. For example, in a book selling system, entities can be Book/User/Recommendation/Review.
Interactor objects implement use-cases, and they typically use multiple entity objects. For example, Purchase_Book/Login/Search_Books can be such objects.
Boundary objects are used for transferring data across module boundaries, and are used for building interfaces between parts of the system, which should be decoupled from one-another. For example, a controller may need to create a Purchase_Book object, and in order to create it, it needs to pass data about what book ID needs to be purchased, by what user ID, etc... and this data can be packed in a boundary object called Purchase_Request.
While Interactor and Boundary require more explanation, I find that the word Entities is meaningful and can be grasped intuitively without reading any explanation.

Entity/Component concepts of GameplayKit

I am designing my game with Entity/Component concepts of GameplayKit in iOS 9, for ShootComponent, should define bullet/missile as Entity?
Reason for Yes:
separate logic from its parent, e.g. playerTank or enemyTank;
if not, TankEntity need distinguish whether its bullet collide with other Entities or itself.
Reason for No:
it is not actual entity in logic world, which is fired by my tank or enemy turret;
bullet always be shot and disappeared, so game need add/remove it now and then;
For your comments pls.
Finally decided to define bullet/missile as entity, so it acts as entity in contact test, rendering and other components.
I would have add it as a component for the entity using it.
So you will be able to make any entity fire bullet or missile.
Keep in mind that your entity should only act as a simple reference with no logic in it.
First lets read Adam Martins original description of his terms. It appears Apple got the idea of entities and components from Martin:
Entity: The entity is a general-purpose object. Usually, it only consists of a unique id.
Component: the raw data for one aspect of the object, and how it interacts with the world.
System: "Each System runs continuously (as though each System had its own private thread) and performs global actions on every Entity that possesses a Component or Components that match that Systems query."
Martin is just defining terms for doing compositional design, which is an alternative to inheritance that is more recombinable and flexible.
So entities are what you might recognize as instances of a class, but classes have been stripped of all their data and methods, which has been moved out into components - and the entities just delegate to the components.
So your missile... it would be an instance of a class in normal OO terms - an object, right? And a missile can behave in a variety of ways... it can seek out an enemy, it can fly straight ahead, it can speed up, etc. It also has properties that indicate if it's hit an enemy, properties for its total damage, health, and so on.
So the missile is an entity while these various methods / data would be components of the missile entity.
Martins approach is interesting, and there hasn't been as much focus on compositional design as there has been OO (for what reason I don't really know), so I can see why Apple would adopt it for a game framework like this.
But his ideas don't seem very well fleshed out. For example, usually in compositional design there is a delegation hierarchy, where objects will keep delegating up a chain until some data or method is found. At the top there's one meta-object that everything delegates to. In this way objects are both components and entities - they act as both the delegating and the delegated to. But Martins terms don't support this... his model is flat - there are only entities, and then components that can be added to them, but no delegation between entities and no meta-object.
Maybe he felt this flat design was appropriate for game development. I have my doubts... you seem to want some kind of hierarchical structure of objects. I would look for a way to mix in inheritance, or setup some kind of custom delegation hierarchy where objects could act as both entities and components. You might look to see if this is possible within that framework, or if it isn't just write your own.

Can a Boundary Class interact with an Entity Class?

For instance: link
Is the above Ok or it would be better to create more methods in Controller that handle the data that are sent/retrieved without the interaction between UI and the Entity?
In general when is it allowed (if it is) for a Boundary Class to interact with an Entity Class?
Depends on whether you want/need to stick religiously to the Boundary-Control-Entity pattern:
If yes (you do need to stick to the pattern): then no, the Boundary object can only speak to Control objects. See table at bottom of this page (also a good description of pattern).
If no: then yes it can!
That's not meant to be glib. It's questionable whether such strict separation is good design practice. It looks nice in pictures: Boundary, Control and Entity in nice horizontal layers with messages passing adjacent layers only.
The reality is rather different. Strict separation can lead to two problems:
A proliferation of pass-through methods. You allude to this. You end up with an amalgamation of methods on the controllers that do nothing more than pass through to the underlying entities.
Anaemic Entity classes. Rather than the Entities being home for data + behaviour, they become data containers only with all behaviour migrating out to controllers. That's not a good thing.
It's notable that in Domain Driven Design, Eric Evans recommends creating Services (akin to Controllers) only when the logic in question doesn't have a viable home in any of the Domain Classes (Entities).

In UML class diagrams, what are Boundary Classes, Control Classes, and Entity Classes?

I'm now using NetBeans as my IDE-of-choice, and it has a plugin for UML modeling. In the class diagram, there are model elements known as Boundary Class, Control Class, and Entity Class. However, I can't find a good definition of them, but I did find this site on UML Class Diagrams.
Robustness diagrams are written after use cases and before class diagrams. They help to identify the roles of use case steps. You can use them to ensure your use cases are sufficiently robust to represent usage requirements for the system you're building.
They involve:
Actors
Use Cases
Entities
Boundaries
Controls
Whereas the Model-View-Controller pattern is used for user interfaces, the Entity-Control-Boundary Pattern (ECB) is used for systems. The following aspects of ECB can be likened to an abstract version of MVC, if that's helpful:
Entities (model)
Objects representing system data, often from the domain model.
Boundaries (view/service collaborator)
Objects that interface with system actors (e.g. a user or external service). Windows, screens and menus are examples of boundaries that interface with users.
Controls (controller)
Objects that mediate between boundaries and entities. These serve as the glue between boundary elements and entity elements, implementing the logic required to manage the various elements and their interactions. It is important to understand that you may decide to implement controllers within your design as something other than objects – many controllers are simple enough to be implemented as a method of an entity or boundary class for example.
Four rules apply to their communication:
Actors can only talk to boundary objects.
Boundary objects can only talk to controllers and actors.
Entity objects can only talk to controllers.
Controllers can talk to boundary objects and entity objects, and to other controllers, but not to actors
Communication allowed:
Entity Boundary Control
Entity X X
Boundary X
Control X X X
Often used with/as a part of OOAD and business modeling. The definition by Neil is correct, but it is basically identical to MVC, but just abstracted for the business. The "Good summary" is well done so I will not copy it here as it is not my work, more detailed but inline with Neil's bullet points.
Good summary - Conceito: Entity-Control-Boundary Pattern
OOAD
These are class stereotypes used in analysis.
boundary classes are ones at the boundary of the system - the classes that you or other systems interact with
entity classes classes are your typical business entities like "person" and "bank account"
control classes implement some business logic or other
Actually, the Robustness Diagrams (or Analysis Diagrams, as they are sometimes called) are just specialized Class Diagrams. They are a part of UML, and have been from the beginning (see Jacobson's book, The Unified Software Development Process - part of the "Three Amigos" series of books). The aforementioned book has a good definition of these three classes on pp 183-185.
Boundary Control Entity pattern have two versions:
- old structural, described at 127 (entity as an data model elements, control as an functions, boundary as an application interface)
- new object pattern
As an object pattern:
- Boundary is an interface for "other world"
- Control in an any internal logic (like a service in DDD pattern)
- Entity is an an persistence serwis for objects (like a repository in DDD pattern).
All classes have operations (see Fowler anemic domain model anti-pattern)
All of them is an Model component in MVC pattern. The rules:
- Only Boundary provide services for the "other world"
- Boundary can call only to Controll
- Control can call anybody
- Entity can't call anybody (!), only be called.
jz
For the records, the Entity-Boundary-Control pattern comes from use-case driven software development and is much older than Scott Ambler's robustness diagrams who only reused the concept.
The pattern is not part of UML, but is closely related to it because it was promoted by Ivar Jacobson (who initiated it in 1992), Grady Booch and Jim Rumbaugh, the founding fathers of UML... and of the Unified process (UP, RUP). In UML it's just stereotypes like any others.
The Wikipedia explains it best, but Control classes correspond to Use Cases, Boundary classes correspond to the association between a Use-Case and an Actor, and Entities correspond to domain objects identified as being involved in the use-case.
The circulars symbols that most UML tools use with predefined BCE stereotypes are also from Jacobson. The robustness rules are just the transposition of the use-case mapping explained above.

Resources