Monday, 25 April 2016

Difference between the Composition, aggregation, association Relationships.

Difference between the Composition, aggregation, association Relationships.

Now first look into the composition:


To understand the design first of all we must know the relationships. The most important relationships are

 Association
 Aggregation
 Composition

Now see the below about each one elaborately.

Association:

Association is a relationship where all objects have their own life cycle and there is no owner.
Let’s take an example of Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers, but there is no ownership between the objects and both have their own life cycle. Both can create and delete independently. This represents the ability of one instance to send a message to another instance. This is typically implemented with a pointer or reference instance variable, although it might also be implemented as a method argument, or the creation of a local variable.

Tuesday, 5 April 2016

Functions in Python with code examples

Functions in Python:

Function is a block of code that is used to perform single action. Functions are reusable. Python has many built-in functions, in additional to that it allows the user to define their own functions which are called as user defined functions.

Defining a function in python:

Python have simple rules to define a function.
Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).
The arguments should be placed within these parentheses. we can also define parameters inside these parentheses.
The first statement of a function can be an optional statement - the documentation string of the function or docstring.
The code block within every function starts with a colon (:) and is indented.
The statement return exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return none.