MVC Architecture

12
MVC Architecture The Model-View-Controller (MVC) design pattern assigns objects in an application one of three roles. Model Object. View Object. Control Object. The pattern defines not only the roles objects play in the application, it defines the way objects communicate with each other. MVC is central to a good design for a Cocoa application.

Transcript of MVC Architecture

Page 1: MVC Architecture

MVC Architecture The Model-View-Controller (MVC) design pattern assigns objects in an application one of three roles.

Model Object.View Object.Control Object.

The pattern defines not only the roles objects play in the application, it defines the way objects communicate with each other.

MVC is central to a good design for a Cocoa application.

Page 2: MVC Architecture

Advantages

MVC is central to a good design for a Cocoa application.

The benefits of adopting this pattern are numerous. Many Objects are reusable.Reusability of the code.Applications which implemented MVC design are more extensible than the other applications.Many Cocoa technologies and architectures are based on MVC.

Page 3: MVC Architecture

Model Objects

Model Objects define the logic and computation that manipulate and process the data.

For example, a model object might represent a character in a game or a contact in an address book.

Page 4: MVC Architecture

View objects

A view object is an object in an application that users can see.

A view object knows how to draw itself and can respond to user actions.

A major purpose of view objects is to display data from the application’s model objects and to enable the editing of that data.

Page 5: MVC Architecture

Controller Objects

A controller object acts as an intermediary between one or more of an application’s view objects and one or more of its model objects.

Page 6: MVC Architecture

Example

Page 7: MVC Architecture

Data Types

Char --character

Int ---- Integer no decimals

Float--- Single precision floating point number

Double--Double precision floating point number

Long--- for long integers

BOOL---YES Or NO.

Page 8: MVC Architecture

Operatrors

What is an operator?In a Math program an operator indicates the action performed in a equation

For Example 4+5 = 9 here + and = is called the operation.

Page 9: MVC Architecture

Arithmetic More Operators

+ -- Addition

- Subtraction

* -- multipication

/ ---Division

% -- Modulo

Page 10: MVC Architecture

Relational and Equality Operators

== equals

!= -- > not equals

> --- > greater

< -- less than

>= Greater than or equal to

<= Less than or equal to

Page 11: MVC Architecture

Logical Operators

! - NOT

&& Logical AND

|| Logical OR

Page 12: MVC Architecture

Control Statements and LoopsIf condition

If else condition

For loop

While loop

Do while

Jump statements