Unified Modeling Language II

At the last blog’s post i uploaded some introduction of what is unified modeling language, you can check it at the link blow: https://wordpress.com/read/feeds/99170391/posts/2428155733

In this post im going to talk about history of unified modeling language and some details of it. In 1994 the creator of OMT (Object Modeling Technique), he invented the this method to merge their idea into a single idea.

By 1995, the creator of OOSE, Ivar Jacobson, had also joined Rational, and his ideas (particularly the concept of “Use Cases”) were fed into the new Unified Method – now called the Unified Modeling Language.

There are several more types of diagrams of UML, such as:

Use cases diagram: describes a sequence of actions that provide something of measurable value to an actor and is drawn as a horizontal ellipse.
Actors: An actor is a person, organization, or external system that plays a role in one or more interactions with your system. Actors are drawn as stick figures.
Associations: Associations between actors and use cases are indicated by solid lines. An association exists whenever an actor is involved with an interaction described by a use case.

Component diagram: are used to model physical aspects of a system. Physical aspects are elements such as executables, libraries, files, documents etc., which reside in a node.

Resultado de imagen para component diagram

Sequence diagram: models the collaboration of objects based on a time sequence. It shows how the objects interact with others in a particular scenario of a use case.

Resultado de imagen para sequence diagram

Activity diagram: are graphical representations of workflows of stepwise activities and actions.

Resultado de imagen para activity diagram

Once you understand all the concepts, let’s start to convert classes to code. For example:

Let’s take a look at this UML:
1. The upper part of the table goes the name of the class, first letter is in Uppercase.

2. The middle part of the table contains attributes of the class, then type of the attributes.

3. The lower part of the tables includes all the method of the class, after the name of the method you have to specify “()” such as howTo().

4. There are some signs, it refers to the access modifier, it goes before the name of the attributes.

  • public = “+”
  • package = “~”
  • protected = “#”
  • private= “-“

5. There are many relation between class to class:

  • Unidirectional one-to-one association:

In the example below, each Account is associated with exactly 1 Advertiser, and the only traversal of the link is from the Advertiser to the associated Account. In this case the Account is created by the Advertiser constructor, and the Advertiser retains a link to the Account, but not vice-versa:

  • Bidirectional one-to-one association:

As above, but now there is a link from the Account to the Advertiser as well as the other way around. The constructor for the Account is still called as a byproduct of constructing an Advertiser, but now it contains a link back to the Advertiser with which it is associated:

  • One-to-many association:

If the Advertiser can have multiple accounts, then the Advertiser needs to have some sort of collection ( Set, List, HashMap, etc. ) to refer to the Account(s). The Account is no longer created by the Advertiser constructor, but rather must be created separately and added to the Advertiser as a separate step. Note that the code below has a problem if Advertiser.addAccount( ) is called before Account.setOwer( ).

  • Many-to-many association:

Now both ends of the association need to use collections, with appropriate checks to maintain the consistency of the associations, and to prevent circular recursion.

Unified Modeling Language

BLOG VI.

Unified Modeling Language also known as UML, it is one of many modeling languages consisting of set of diagrams, developed to help system and software developers in order to specify, visualize, construct and document the software system.

We can say that UML is very important in area of object-oriented because it uses mostly graphical notations to express the design of software projects. Using the UML helps project teams communicate, explore potential designs, and validate the architectural design of the software. The goal of UML is to provide a standard notation that can be used by all object-oriented methods and to select and integrate the best elements of precursor notations. UML has been designed for a broad range of applications. Hence, it provides constructs for a broad range of systems and activities.

But, why choose UML?

  1. Provide users with a ready-to-use, expressive visual modeling language so they can develop and exchange meaningful models.
  2. Provide extensibility and specialization mechanisms to extend the core concepts.
  3. Be independent of particular programming languages and development processes.
  4. Provide a formal basis for understanding the modeling language.
  5. Encourage the growth of the OO tools market.
  6. Support higher-level development concepts such as collaborations, frameworks, patterns and components.
  7. Integrate best practices.

In UML, since there is many type of stakeholders, it is necessary to have different types of diagrams, because each one of the stakeholders have their own interests in different aspects of the system.

  • class diagram: class diagram is a central modeling technique that runs through nearly all object-oriented methods. This diagram describes the types of objects in the system and various kinds of static relationships which exist between them.
  • object diagram: represents an instance at a particular moment, which is concrete in nature. The use of object diagrams is fairly limited, namely to show examples of data structure.

Here is the link if you would like to know more about UML:

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-uml/

Design Patterns

BLOG V.

In this part of blog, im going to talk about design patterns. So what are the design patterns? we can say that are typical solutions to commonly occurring problems in software design. They are like pre-made blueprints that you can customize to solve a recurring design problem in your code. Despite the patterns give you the structure of your program it doesn’t mean that patterns give you the code for your program, hence we can say that patterns are high-level description of a solution.

Patterns consists of 4 elements:

  • Intent of the pattern briefly describes both the problem and the solution.
  • Motivation further explains the problem and the solution the pattern makes possible.
  • Structure of classes shows each part of the pattern and how they are related.
  • Code example in one of the popular programming languages makes it easier to grasp the idea behind the pattern.

But why do we need to know about design patterns? well, nowadays many programmers doesn’t even know a single pattern or they don’t even know if they are using a pattern or not, even though you don’t have any knowledge of it, you can become a good programmer, now let’s talk about the reason which you should learn it.

  • Design patterns are a toolkit of tried and tested solutions to common problems in software design. Even if you never encounter these problems, knowing patterns is still useful because it teaches you how to solve all sorts of problems using principles of object-oriented design.
  • Design patterns define a common language that you and your teammates can use to communicate more efficiently. You can say, “Oh, just use a Singleton for that,” and everyone will understand the idea behind your suggestion. No need to explain what a singleton is if you know the pattern and its name.

Design patterns can differ by their complexity. The most basic and low-level patterns are often called idioms. They usually apply only to a single programming language.

The most universal and high-level patterns are architectural patterns. Developers can implement these patterns in virtually any language. Unlike other patterns, they can be used to design the architecture of an entire application.

In addition, all patterns can be categorized by their intent, or purpose. This book covers three main groups of patterns:

  • Creational patterns provide object creation mechanisms that increase flexibility and reuse of existing code.
  • Structural patterns explain how to assemble objects and classes into larger structures, while keeping the structures flexible and efficient.
  • Behavioral patterns take care of effective communication and the assignment of responsibilities between objects.

Here is a video related to design patterns:

Here is a link for more information:

https://refactoring.guru/design-patterns