Layered Architectue

Sunday, June 15, 2008

Charith(044015)

Domain centric means to derive all design from a business architecture perspective.

Domain-driven design (DDD) is an approach to the design of software, based on two premises .For most software projects, the primary focus should be on the domain and domain logic (as opposed to being the particular technology used to implement the system) Complex domain designs should be based on a model.

The term was coined by Eric Evans' book of that title. The book articulates a number of high-level concepts and practices, such as: Ubiquitous language: the domain model should form a common language for describing system requirements, that works equally well for the business users or sponsors and for the software developers. plus a number of specific software design patterns, such as: Entities (a.k.a. Reference Objects): An object in the domain model that is not defined by its attributes, but rather by a thread of continuity and identity. Value Objects: An object that has no conceptual identity. These objects describe a characteristic of a thing. Repository: methods for retrieving domain objects should delegate to a specialized 'repository' object such that alternative implementations may be easily interchanged. Factory: methods for creating domain objects should delegate to a specialized 'factory' object such that alternative implementations may be easily interchanged. Service: When an operation does not conceptually belong to any object. Following the natural contours of the problem, you can implement these operations in services.

The goal is to construct a technology independent application that retains business objects in original form. To do this an application’s architecture is decomposed

This approach while simple supports long term growth using highly cohesive and loosely coupled software layers that allow change in technology and business processes that would otherwise cause failure in most software structures.

Presentation layer

This is where you find the user interface logic. This logic captures how a user (or other actor) interacts with the application. This interaction includes a common look & feel, and work flow specific to each actor. In addition to each view there may be more than one type of presentation, i.e., (Web, Thick Client, Wireless Application Protocol, etc).

All presentations and views are built on top of the same domain model. Handles presentation layer requests, Defines jobs the software is supposed to do. Coordinates tasks and delegates work to collaboration of domain objects in the next layer down. Can have state that reflect the progress of a task for the user or the program.

Application layer

This layer mediates between the various user interface components on a GUI screen and translates the messages that they understand into messages understood by the objects in the domain model. It is responsible for the flow of the application and controls navigation from window to window. This layer is often partially generated by a window-builder and partially coded by the developer.

Domain Layer

Heart of business software. Technical detail of storing these rules is delegated to infrastructure. Handles application layer requests. A couple of key design goals are

Capture and retaining the business architecture in its purest form. Support for multiple presentations and views without need for specific customization of the domain layer to the needs of any one specific point of view.

When driving software construction from the domain layer the concepts within this layer are reflected outward throughout the other layers in a vertical fashion. Once again reinforcing the idea of driving design from the business architecture.

Persistence Layer

Persistence is where we map data to/from the domain model and long-term storage

By encapsulating persistence in its own layer of functionality it could even be implemented as a remote interface to a distributed system instead of directly talking to an underlying storage device, and from the domain model’s perspective this would be transparent.

Benefits of Layered Architecture

Separating the domain layer from the infrastructure and user interface layers allows a much clearer design of each layer. Isolated layers are much less expensive to maintain, because they tend to evolve at different rates and respond to different needs. This seperation leads to reuse.

1. Modularity, low-coupling – easier maintenance.

2. Business-logic is separated from presentation – reuse.

3. General technical services, e.g., database, are

separated from the business-logic – reused, replaced.

4. Low coupling, separation of concerns – evolving functionality, system scaling-up, adapt to new Technologies

The separation also helps with deployment in distributed system, by allowing different layers to be placed flexibly in different servers or clients, in order to minimize communication overhead and improve performance.

Added by Indika (044051)

Smart UI Anti Pattern

So far we have discussed layered architecture related to domain isolation. Actually it is ideal for software project with more functionalities and more complex domain requirement.

Consider a small project with simple functionalities. If we select domain driven approach the design of the project will became more sophisticated. It may require some time to design the architecture in layer wise But more frequently those projects are given limited time to complete. This type of situation to it is better to choose smart UI anti pattern approach to carryout the project in very simpler and productive way.

What is Smart UI Anti pattern?

Smart UI anti pattern is alternative for layered approach and mutually exclusive from domain isolation. It decouples all the layer functionalities and embedded in to the user interface. So we can’t see any domain isolation here.

Where to apply Smart UI anti pattern?

Case 1:

Suppose Software Company is given a project with simple functionality and it has short time period to finish the project. Still all the domain requirement has not been verified it will take some time to clarify the entire domain requirement. Also there is a possibility of changing business functionality is very high.

Case 2:

Suppose a company has junior staff and they are not experience in domain driven design approach at all. If the management decided to do the project using domain driven approach, it will require considerable time to train the staff. But it is not productive with given time schedule of the project. And also it has some risk as they are doing this type of project in first time. So the possibility of the failure is very high.

Case 3:

There may be situations all the domain requirement has not been clarified and but customer need some modules to be finished with clarified requirements. If we select domain driven approach we have to wait until the domain layer is finished. So it is not possible to release a module of the project with identified requirements. So again smart UI anti pattern approach is ideal to address these types of situations.

Advantages

1. Productivity is high and immediate for simple applications.

It will take less time to finish each module and earn profits.

2. Less capable developers can work this way with little training

3. Even deficiencies in requirement analysis can be overcome by releasing a prototype to users and then quickly changing the product to fit there requests.

4. Applications are decoupled from each other, so that delivery schedule of small modules can be planned relatively accurately. Expanding the system with additional, simple behavior can be very easy.

5. Relational databases work well and provide integration at the data level.

6. When applications are hand off, maintenance programmers will be able to quickly redo portions they cant figure out, because the effect of the changes should be localize to each particular UI.

Disadvantages

1. Integration of applications is difficult to except through the databases

2. There is no reuse of behavior and no abstraction of the business problem. Business rules have to be duplicated in each operation to which they apply.

3. Rapid prototyping and iteration reach a natural limit because the lack of abstraction limit refactoring options.

Layered Architecture

This is the Draft of the Presentation we are going to do on "Layered Architecture".


Entities and Value Objects

Monday, June 9, 2008

by Dasith Gunawardana
Today we are going to discuss about the Entitles and the Value objects. You can find todays presentation in our previous post.

Here is the overview of what we are going to discuss today.

  • Domain Driven Design
  • Model Driven Design
  • Elements of a Model
  • Entities
  • Value Objects
  • Entities Vs Value Objects

So as I start with my presentation, let’s look at what is a Domain Driven Design. Actually Domain Driven Design is an approach to the design of the software based on two premises. In Domain Driven Design the primary focus should be on the domain and the domain logic. The Domain is the area in which the system is going to implement and the domain logic is the process of the system.

In most occasions complex domains are based on a Model because of convenience of understanding the system features.

In a Model Driven Design Analyst responsibility is to capture the fundamental concepts of the domain in a comprehensive manner.

But the designer has to specify set of components that can be constructed with the programming tools to use in the project.

Therefore a Model Driven Design eliminates both issues in Analysis model and design to come up with a single solution which serve both purposes.

Actually a Model Driven Design is software that structures around set of concepts which gives more concern to translate the Model in to code for different technological platforms.

This is the high level view of expansion of the Model Driven Design.













The Model Driven Design comprises of Services, Entities, Value Objects, Layered Architecture and Smart UI which again expand the Entities ad Value objects to Repositories, Aggregates and Factories. But here in our presentation we will be mainly focusing the Entity and Value Objects.


by Eranga Wijebandara - 044046

What is entity?
Many objects are not fundamentally defined by their attributes, but rather by a thread of continuity and identity.

This entity object can be easily understand using general example. Take a person he has lot of attributes such as name, color, etc...These attributes are changed during the life time. But even these attributes has changed we can identify that particular person.The reason for that is identity persists.

As same manner object can be identify using it's identity. So during the life cycle of the object the identity will never change.But attributes can be change such as definition,responsibilities , association etc.

Mistaken identity will make lot of problem.

Example:
"A landlady sued me, claiming major damages to her property. The papers I was served described an apartment with holes in the walls, stains on the carpet, and a noxious liquid in the sink that gave off caustic fumes that had made the kitchen wallpaper peel. The court documents named me as the tenant responsible for the damages, identifying me by name and by my then-current address. This was confusing to me, because I had never even visited that ruined place.

After a moment, I realized that it must be a case of mistaken identity. I called the plaintiff and told her this, but she didn't believe me. The former tenant had been eluding her for months. How could I prove that I was not the same person who had cost her so much money? I was the only Eric Evans in the phone book.

Well, the phone book turned out to be my salvation. Because I had been living in the same apartment for two years, I asked her if she still had the previous year's book. After she found it and verified that my listing was the same (right next to my namesake's listing), she realized that I was not the person she wanted to sue, apologized, and promised to drop the case."(Reference:Domain Driven Design by Eric Evans)

So same thing apply to object as well .A case of mistaken identity in a software system lead to data corruption and program error.


by Chathurika Sandarenu - 044034

We now know that the Identity is the most important thing in an Entity. This identity of an Entity can even be applicable outside the application domain. For example we can consider in a Banking application it use account no to uniquely identify accounts. We use this identity; account number to identify an account in general, in our day today lives.

But some identities do not have a meaning when we take it out of that particular application. For example in Operating Systems, it gives unique ID to each process running. If we take that process id alone, without considering the OS it do not have any meaning.

This Identity of an Entity we are talking about is directly depends on the application domain. Depending on application we may choose some objects as entities and same object may not be choosen as an Entity in another application. The idea of Identity does not necessarily have to mach with our real world experience. Things we consider as unique may not consider as unique in some software applications. What is choosen as Entity and their Identity is directly depends on the domain model.

For example if take the object “Seat” in a “Seat Booking” application we have to take it as an Entity since we need to uniquely identify individual seats. But if we consider “General Admission” scenario “Seat” need not to be an Entity. Since in “General Admission” we consider all seats same, we do not need to find out the identity of individual seats.

Litmus test of Entity is the Identity. Doesn’t matter the attribute values are changed in two instances of objects, if those two instances have same identity then they are from same Entity. We can use the same concept with humans, over the time our appearance changes, skin wrinkles, hair color changes, and so many things happen, but still our identity remains same….

Modeling Identity

This is the most important thing regarding Entities. Entities are the most important objects in our domain. When modeling them we have to make sure that they are both lean and powerful. When modeling Entity it is better to keep it as simple as possible. Only put attributes that are necessary to represent the identity. Put anything else into separate objects. Those separate objects can either be Entities or Value Objects. So this way we can have a hierarchy of objects which are attached to one CORE ENTITY. This is also known as aggregate.

Next Important thing, when modeling Entity is what to choose to represent Identity of the Entity. This can be done in many ways depending on the application. One method is to use some attributes or combination of attributes as identity. For example we can use NIC as Identity for Person object, or we may use combination of attributes such as Name and DOB. Another method is to use auto generated IDs. When we use database applications we can use DBMS to auto generate keys and we can use that same key as Identity of our Entity.


by Wajira Somarathne - 044038

Value Objects:

Lets talk about value objects. First think about following 3 circles.




They can be uniquely identified. Because they are colored in 3 different colours. So we can identify each circle by its own colour. Now we will think about this scenario: now think about following 3 circles.




Can you identify each other separately. No .. We can’t. Because each circle is same as others. Lets think we are creating a new shape using this 3 circles like this.






Can you find which circle is on the top, which is at the left and which is at the right? We cannot. And there is no effect whether 1st circle is on the top or left or right. These kinds of scenarios will be occur in the object modeling also.

We use value objects to address this kind of scenarios by giving more performance to the system. According to the common definition, An object that represents a descriptive aspect of the domain with no conceptual identity is called a value object. Value objects are instantiated to represent elements of the design that we care about only for what they are, not who or which they are. That means value objects are not concerning about the identity of each real world things. Value objects are commonly share the attributes of them.

Lets take an example: In software for a mail-order company, an address is needed to confirm the credit card, and to address the parcel. But if a roommate also orders from the same company, it is not important to realize they are in the same location. So Address is a VALUE OBJECT in this case.


By W.G.K.D. Karunarathne - 044022

Consider the Scenario 3.In a software for an electric utility company an address can be considered as an entity object because it corresponds to a destination for the company’s lines and service. If roommates each called to order electrical service, the company would need to realize it. Address is an entity. Alternatively, the model could associate utility service with a "dwelling," an entity with an attribute of address .In this case address can be consider as a value object.

In model driven design approach it is better to use value objects. Even though many programmers think entity objects are better but value object are much powerful than entity objects. We can use value objects in communication to increase the network performance. We can make copies from value objects (not like entity objects) and can send copies of value objects to the client side from server side. On the other hand if we use entity objects need to send objects for client’s each and every request separately. This will caused to increase the server load.

Value objects must be immutable. We cannot change the existing value objects. If we need to change them we need to destroy the object and recreate them. So we can send copies of value objects in communication. As we can use value objects for data transfer we called them as data transfer objects. Value objects can be assembling from other objects. They can be made up of other value objects as well as other entity objects.

Both entity and value objects are principles. We can’t say these are important and these are not important. Entity identity is important and value objects are only for values. But value objects will be more programmatically efficient.


by Anushke L. N. Guneratne - 044014

Odds and ends on Value objects and a Conclusion

As we can see from the posts of others in my group, it is clear that the seperation of entity and value objects is done at the design stage, specially where it is in reference to model driven design.

There are cases when we need to contain some attributes of a domain element. We are not interested in which object it is, but what attributes it has. An object that is used to describe certain aspects of a domain, and which does not have identity, is named Value Object.

Having no identity, Value Objects can be easily created and discarded. Nobody cares about creating an identity, and the garbage collector takes care of the object when is no longer referenced by any other object.

Value objects can be part of a entity object, or it can refernce to entity objects.

Bottom line is in conclusion,
- Value objects are programatically efficient, and are sometimes called Data Tansfer Objects.
- Entity Objects are NOT just an important object, but rather Objects where the Identity is important
- Whilst Value objects are objects where the value is important.

Lecture 1 : Introduction to Software Engineering and associated complexities, OOP overview, grouping and other odds and ends

Sunday, June 8, 2008

The first lecture conducted by Mr. Harsha dealt with going back to OOP (Object Oriented Programing) and its fundamentals of design. The deviation of the subject matter from the previous lectures where we were discussing about the need for mathematical basis and about OCL was a surprise.

Several in class activities were conducted in an effort to clarify to the students of the proper need for modeling. It was clear by the end of those that different people would model the same problem in several ways depending on their domain understanding. i.e. they will use the head knowledge to bring about the design. This of course we must understand is detrimental to any proper design, as it will create ambiguities in the documents outlining the design.

If careful observation was made at the end of the day we can see that this lecture looked at the need for a proper design basis (i.e. a mathematical basis perhaps as outlined in an earlier lecture) when it comes to OOP.

The slides used for the presentation highlighted why software was complex, (and also the reason why software engineers are purportedly receiving higher pay) due to.

  • Complexity of Problem domain
  • Development process management
  • Flexibility
  • Contradictory requirements
  • User/Developer mis-communication

At the end of the day it goes without saying that the vehicle of communication within which we will be learning about Advanced Software Engineering would be OOP. So its fair to expect that during the course of this module we will be seeing aspects of(hmm…)

  • Object Oriented Analysis
  • Object Oriented Designing

So during the last bit of the lecture there was a re-cap of earlier learned fundamentals present in OOP. These are:

  • Abstraction
  • Encapsulation
  • Modularity
  • Hierarchy

The day concluded with groups being made out so that they will be presenting different topics during the rest of the module.

So ended the lecture where over 100 students were in a room designed to hold 64. (no pun or complaint or offense intended)


P.s. we were all asked to blog about the lecture as well as create facebook accounts and groups for the lecture. Hence the blog post. :)

Entities and Value Objects

Thursday, June 5, 2008

 

This is the draft of the next Monday's presentation that we are going to do. Even though there will be few modification in the final version, this will be a great help for you all to come prepared...

This is the final version of the presentation, so go through it and come prepared :)

You can also view the full screen version of the presentation through this link.

WHY IMPLEMENTATION INHERITANCE IS BAD.

There are two types of Inheritance.

§ Implementation inheritance: Implementation inheritance allows a super class and a subclass to share identical code for the same method.

§ Interface Inheritance: inheritance wherein one or more classes share a set of messages.

Multiple Inheritance

Both Car and Boat classes inherit from vehicle supper class. Here Car and Boat are child classes.


Diamond Inheritance

Imagine, a smart company builds a vehicle that can be travel on land as well as water called CarBoat (which has properties of Car and Boat)(figure2).

Figure2



W.G.K.D. Karunarathne (044022)
Level4

IDENTIFYING OBJECTS AND CLASSES FROM REQUIREMENT SPEC

Software Requirement Specification (SRS)

Requirement Specification is use to plan the project and finalize the requirements at the initial stage of the project. The main reasons is for using a spec, because of the requirements are not clear at the initial stage of the project and need to come up with a sigh in document with the client by capturing requirements as much as possible. There may be lot of contradictions in the early stage of the document. Then come up with an object oriented design with the help of business analysts and do a requirements analysis process. Then latter stages requirements can be clearly identify and can do the necessary modifications to the specification. There are different techniques to identify classes from a SRS.

  • Textual analysis

A class is conceptually a set of objects of the same kind, and objects represent ‘things’ in the system domain. So nouns and noun phrases in the requirements document can be used as an aid to identifying possible classes. But there are some problems in this method. Such as sometimes nouns and noun phrases are duplicated, have to deal with different ways of referring to the same thing (eg. Member and library member, title and film title etc.), same word ay be used to refer different things (Number can be used to represent Number of DVDs and number of members). There are some guide lines for rejection of candidate classes. Following are some questions that help to reject the candidate classes.

§ Is it a property?

§ Does it refer to a behavior of the system?

§ Is it outside the scope of the system?

§ Does it refer to an aspect of the user interface?

§ Does it refer to connections between other significant entities in the system domain?

§ Is it a word or phrase that is used in talking about systems in general, rather than a reference to something in the system domain?

  • Class Responsibility Collaborator Cards (CRC cards )
A Class Responsibility Collaborator (CRC) model is a collection of standard index cards that have been divided into three sections, as depicted in following figure. Each class has responsibilities. Classes cannot fulfill those responsibilities alone. Classes need to collaborate with other classes and interact with those classes. In simple way a class represents a collection of similar objects, a responsibility is something that a class knows or does, and a collaborator is another class that a class interacts with to fulfill its responsibilities

figure1

Abstract class

An abstract class is a type of class that cannot be instantiated; it merely exists to be extended and contains methods and variables common to all sub-classes. For example consider a hospital system (figure 2).

figure2


Class Categories

There are 3 types of classes.

¢ Analysis classes

— Data abstraction directly drawn from the model of the external system

¢ Design Classes

— describes a data abstraction introduced for the internal needs of the algorithms in the software

¢ Implementation classes

— There are two types of implementation classes.

— 1.Typed implementation classes: A class that implements a concrete class. Implementation classes are never used directly.

— 2.Typeless implementation classes: A class that implements a concrete class and provides an interface that is not specific to a given element type.

Ideal Class

A class that has a clearly associated abstraction, which can be described as a data abstraction (or as an abstract machine). The class name is a noun or adjective, adequately characterizing the abstraction. The class represents a set of possible run-time objects, its instances. (Some classes are meant to have only one instance during an execution; that is acceptable too.)




W.G.K.D. Karunarathne(044022)
Level 4