Swordrock's Blog

Just another WordPress.com site


Today i am introducing one of excellent programming language : C++ . Cpp is an object oriented programming language (called OOP)  which does its work by using objects .

We , who used to work with non objective languages like C and other old languages , will get object using priniciples day by day . But it is not a sudden process . We will learn slowly , but smart .Now i will share what is general features of C++,How Objects are important to us , Analysis and Design methods

Five top feature of C++ ;

1)     Everything is an object

2)     A program is a bunch of objects telling each other what to do by sending messages

3)     Each objects has its own memory made up of other objects

4)     Every object has a type

5)     All objects of a particular type can receive the same messages.

As you see five feature one subject : object 🙂


1)     What are the objects ? (how do you partition your project into its component parts )

2)     What are their interfaces ? (what messages do you need to be able to send to each object)

Here a wiki link that explains OOP : http://en.wikipedia.org/wiki/Object-oriented_programming

Now lets make a plan to write the code,it has 5 parts :

Part1-make a plan

First decide which steps you will use in your process .

The mission statement : any system you build has a fundamental purpose.So we can write the core of it in 3 or 4 sentence.

Part2-what is the work

Determine what the system is supposed to do .

#who will use this system ?

#what can those actors do with the system

#how does this actor do that with the system

#how else might this work if someone else were doing this , or if the same actor had a different objective ?

#what problems might happen while doing

But you may use a short way : describe the system in a few  paragraphs and then look for nouns and verbs . The nouns can suggest actors , verbs can suggest the interactions between actors and use cases .

Also nouns and verbs will produce objects and messages .

Part3-how to build it ?

You must come up with a design that what will classes look like and how they will interact ?

An excellent way to do this is Class Responsibility Colloboration (CRC)

You start out with a set of blank 3 “by 5” . Each card represents a single class . Card building will be in our brain as hard as we work on C++ .

1)the name of the class . this name capture the essence of what the class does , so it should make a sence at a glance

2)the responsibilities of the class : what it sould do . this can be summarized by just stating names of the member functions

3)the collaborations of the class : what other classes does other interact with ?

1)Thinking in C++

Five stages of Writing

1)     Object discovery

Initial analysis of the program .

2)     Object assembly

Later , you will discover some class is missing , you missed while discovery .

3)      System construction

More requirements for an object may appear in the later stages.

4)      System extension

When you apply new objects or methods , you may discover that new design doesnt support with previous .

5)      Object reuse

This is the real stress test for a class .

Guidelines for object development

#let a specific problem generate a class , then let the class grow and mature during the solution of other problems .

#remember discovering the classes you need is the majority of the system design .

#dont force yourself to know everything at the beginning , learn as you go .

#start programming get something working so you can prove or disprove your design . Dont fear that you will end up with procedural-style spahetti code-bad classes dont break good classes .

#always keep it simple . little clean objects with obvious utility are better than big complicated interfaces .

Use occam razor’s approach  :

!When decision points come up , consider the choices and choose the simplest . You can extend and develop your class when you understand it.!

Here is an article about OOP theory : http://www.devx.com/opinion/Article/26776

See you at another lesson !


Ekim 24, 2010 - Posted by | C/C++ programming | , , ,

Henüz yorum yapılmamış.

Bir Cevap Yazın

Aşağıya bilgilerinizi girin veya oturum açmak için bir simgeye tıklayın:

WordPress.com Logosu

WordPress.com hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Google+ fotoğrafı

Google+ hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Twitter resmi

Twitter hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Facebook fotoğrafı

Facebook hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )


Connecting to %s

%d blogcu bunu beğendi: