Skip to content
February 14, 2013 / Danii Oliver

Procedural – Object-Oriented Analysis and Design

What problems were we trying to solve ?
The Basics of programming is creating …
types, variables, function, subroutines, modules

Programming and OOP is about getting further away from Machine language and closer to human language

Procedural
Procedural – doesn’t allow for reuse
– abstract datatypes
– would have to write the rules in a function
– where to put data nothing else or if it should have something else

Type allows what values can be stored based on a certain range
i.e. int is whole numbers only neg or pos
uint only positive whole numbers

Procedural
user defined type or abstract data type – not predefined and used to define something more
|–>Student {
string fname
string lname
int age
}
this is the limit in Procedural Language
student s; or var s:student;

Type Checking – compiler checks to make sure all vars are compatible and that and operators make sense for the type

Semantics or Rules is about checking that the type contains what it is suppose to.

Global Variables can do more harm than good. Fact!

Scope/Visibility:
void foo(){
int x;
y = x;
}
– inside the { } is the scope of the function or code block the var inside is Local
if
void Main{
foo();
x = x+5; [[ error x is undefined because x is local to foo ]]
}
if at TOP int y; //Global
then y can be cast anywhere
void Main{
foo();
x = x+5; [[ error x is undefined because x is local to foo ]]
y=y+20; [[ y will get recasted ]]
}

abstract data type does not answer a query the function does but there is no communication

Object-Oriented
OOP goes from
[ Data ]
[func][func][func] to
[ data | behavior & cap ] [ data | behavior & cap ] [ data | behavior ]
– not all things but the things that are in common.

** Procedural is a Child that knows but others must speak for them
** OOP is a person who can speak for themselves

Classes are classifications for complex objects made of various variable declarations or fields whose scope is the class

Classes describes how an Object is made, what it can do, can’t do, allowed to do

To go from having a Class ( or your recipe ) to an Object we Instantiate the class which gives is a memory block. Type determines amount of memory. Class = Type.

Instantiation is the process of requesting the amount of memory needed for Class as an Object
now all you need to do is say
student s; ⇒ give me the amount of memory needed now you have an object
new student s; we use “new” so the compiler knows to check how much is needed and get it.

Instead of making an ab.dt that is just data in OOP we can know what the element can do with the data. The blueprint is the Class, if you want it to not be able to do something it should not be in there.
Class describes what an object does and how it does it.

when trying to build a program I am not looking for procedures I am looking to implement an Class Object

The task at hand is the figure out what your classes are to model in your program
student, furniture, light, door — ask yourself what do you need to “represent” this is a real thing.
step two
what are they suppose to do, why are they there, what’s their role, what are their capabilities

NFL Team
program = team
classes = positions on the team
now how many will you need and which ones, why do you need ?
– inside the class are variables &
– behaviors are your functions or “Method” it allows the class to do something ( the action or what it can or can’t do )
– the class doesn’t do anything it defines what the object can do

Job Description is the class – a definition of something
The Candidate is the Object – the object should and will only do what is in the class.

at Runtime you create variables of the classObject

class Student {
int age;
string fname
string lname
}
string Read() {…}
int getAge(){ return age }
int setAge() { this.age = age; }

** Being able to design a system is higher up the food chain than being able to program it. The value is being able to design something that makes you not the commodity and makes you invaluable!
** Those who can marry multiple focuses will have more value especially when married with strong Foundation

UML
Unified Modeling Language: defines the classes that you have and what their relationships are to each other
– static view of the program, a blueprint no paths from point A to B just where they are
– not a flowchart which shows procession

Class : It is best to name your class descriptive of the real word element you are representing
__________
| student |
| |
| |
|_________|

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: