Kari’s Weblog

expressions unlimited

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 864 other followers

  • Twitter

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • Find me on

  • Bookmarks

  • Categories

Object-oriented pragramming using stuctured programming language

Posted by karthikjcecs on August 27, 2007

“C” is my first programming language. I learnt it quite good in my 5th, 6th sem of engineering and I got good interest in programming. I used to do all programs in C. I was thinking of “why to use object -oriented(O-o) when everything is possible in C?”

My vision towards O-o changed when I started on a project in IBM-ISL as an internship program in my 8th semester. There I clearly found out why object oriented is required, its power and ease of programming.

Now I am working on a project which uses C language and I am finding it difficult to understand existing code and to change code is even painful. The project is embedded software, here optimization is of great concern, so one cannot use O-o language for this.

So I thought of why cannot we write structured programs in an object oriented fashion. Some tips came into my mind. Those as follows,

1. Dont use extenal variables.

If you want to share variables among files, follow these:

a. Create static global in the file. Write get and set functions for each static variable. (get function returns the variables value, set function sets the value)

b. Create a header file, declare all the public functions in it. (Like those get and set functions)

c. Those who want to access the variable should include the created header file.

This helps in data abstraction to some extent. Finding the files which access the specific variable becomes easier ( Files which includes header actually uses it )

2. modularize by creating a file for specific function. Should be able to describe the purpose of the file very clearly (Just like class declaration. My idea is to create on file instead of one class here )

Well, its not difficult to break this. Programmers should have such standard conventions and make it easier of a third party to make changes. Even though if we follow this in the future if some one comes and declares the variable externally, it fantastically works, but industry should not allow it to happen, should maintain convention.

These what I felt. It may be totally crap :(, Or may have some value. May be we can improve in this regard. Or even some one might have already thought of it ( I don know )

programmers comment on this.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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: