Structured and object oriented programming

Thread Starter

Parth786

Joined Jun 19, 2017
642
A programming language is set of instruction written for a machine. Programming languages are designed to make it easy for humans to write complex instructions. we write statement and function in programming language. Structured programming and object oriented programming used in computer science , they are both useful to programmers.

I started reading about structured and object oriented programming but I am confuse I don't understand meaning of structured and object oriented programming. I am looking help to understand difference between structured and object oriented in programming. I saw this link helpful https://en.wikibooks.org/wiki/The_C...ng/Object_Oriented_vs._Structured_programming but still confuse

Please help me to understand the use of Structured programming and object oriented programming in real world..
 

MrChips

Joined Oct 2, 2009
30,706
It is not a question of Structured Programming (SP) vs Object-Oriented Programming (OOP).

OOP is layered on top of SP.
SP is fundamental. OOP is an extension of SP, in the same way C++ is an extension of C.

OOP takes the philosophy of modularity and reusable code two steps forward.
OOP is based on the concept of encapsulation, properties and methods, classes, and inheritance.
OOP is based on the concept of actors or objects, belonging to a class and having common properties and behaviors. These properties and behaviours can be inherited from "parent" objects and propagated to "child" objects, hence "inheritance".
The OOP paradigm is that of independent autonomous objects and classes which can be reused and called into action without having to reinvent every new object.

For example, look at your browser screen. How many different types of action buttons do you see on one widow? Imagine if you had to write the code for each and every one of those buttons. Instead, you can create one class of objects called "button" and call the same code for all the different buttons. Each button has a different style, colour, location, label, and function. Yet, we can create a single set of properties and methods for all buttons.

Summary, you can use Object-Oriented Programming to make programming easier. Structured Programming fundamentals still remain useful and valid.
 

nsaspook

Joined Aug 27, 2009
13,079
You can use the principles of Structured and Object-Oriented Programming in any language include Assembly. (if that trips your trigger)

In C the usage of data structures with pointers to data and functions (procedures) allow for the abstraction of limited Object-Oriented lite Programming. For most embedded projects you don't need the full C++ language.
https://www.state-machine.com/doc/AN_OOP_in_C.pdf

Some of these OOP methods were used in the interface software for this projects software. We have different display/control methods for different motor and unit types but only one function call to handle them all.
https://forum.allaboutcircuits.com/threads/mandm.75507/

C:
// code fragments
typedef void (*display_func)(void);

struct modetype {
    volatile uint8_t demos, move, free, operate, demos_init, slow, emo, v24, cal, on_off_only, idle, locked, info_only, qei, slow_bypass, change;
    display_func display;
};
volatile struct modetype mode = {FALSE, TRUE, TRUE, HELP_M, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE};

// program default mode.display
void default_display(void)
{
// display code
}

// another possible LCD display function for the mode.display
void emo_display(void)
{ // System has detected a condition that caused it to stop in a safe comdition
    sprintf(bootstr2, " EMO EMO EMO EMO      ");
    LCD_VC_puts(VC0, DS1, YES);
    sprintf(bootstr2, " Power Cycle/Reset    "); // info display data
    LCD_VC_puts(VC0, DS2, YES);
    sprintf(bootstr2, " Assy Wiring Short?   "); // info display data
    LCD_VC_puts(VC0, DS3, YES);
}

mode.display = default_display; // display screen function pointer

void nav_menu(void) // call the correct screen display function
{
    Set_Cursor();
    mode.display();
}
Set_Cursor configures the mode 'object' global data then mode.display executes the mode 'object' code.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
@MrChips @nsaspook Sorry but still I don't understand what is class and object in programming.

I have installed IDE for C and Java programming in my computer. I can write program in C language. I don't have much knowledge on java programming. I can run the program on eclipse

java1.jpg

Can we go through any program to understand what is the difference between object class and structure. In c program structure is used to store multiple type of data like int , char.

If we take a simple example, it will help me more
 

nsaspook

Joined Aug 27, 2009
13,079
@MrChips @nsaspook Sorry but still I don't understand what is class and object in programming.

I have installed IDE for C and Java programming in my computer. I can write program in C language. I don't have much knowledge on java programming. I can run the program on eclipse

View attachment 146268

Can we go through any program to understand what is the difference between object class and structure. In c program structure is used to store multiple type of data like int , char.
It's time for you to hit the books again on both C and programming in general.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
It's time for you to hit the books again on both C and programming in general.
Yes, I am doing this. I am studying book for c programming. at the starting of book on the 4th page. there is description about structured and object oriented programming but there is not much description. I spend some time on google and I found the bunch of materials but I did not understand it the real meaning.
 

nsaspook

Joined Aug 27, 2009
13,079
Yes, I am doing this. I am studying book for c programming. at the starting of book on the 4th page. there is description about structured and object oriented programming but there is not much description. I spend some time on google and I found the bunch of materials but I did not understand it the real meaning.
Sure, you want to fly without learning how to walk, it's a familiar tale.

http://www.compileonline.com/index.htm
 

MrChips

Joined Oct 2, 2009
30,706
Let's be honest. You are not ready yet for object oriented programming.
You are not ready yet for advanced topics such as structures in C.
You still have not mastered basic algorithm design and control structures.
You still need to work on pointers, interrupts, timers, semaphores, multi-tasking, scheduling, etc.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
Let's be honest. You are not ready yet for object oriented programming.
You are not ready yet for advanced topics such as structures in C.You still have not mastered basic algorithm design and control structures.
You still need to work on pointers, interrupts, timers, semaphores, multi-tasking, scheduling, etc.
I am totally agree with your statement's, this chapter was in C programming book at starting. I think I should just leave this chapter and I should focus on next chapters
 

JohnInTX

Joined Jun 26, 2012
4,787
Yes, I am doing this. I am studying book for c programming. at the starting of book on the 4th page. there is description about structured and object oriented programming but there is not much description. I spend some time on google and I found the bunch of materials but I did not understand it the real meaning.
Adding to the others' and what you posted while I was typing, it's common in the opening pages of a book to have a broad overview of the subject. It doesn't mean that you have to master the topics just because they are mentioned to proceed. Just get on with the simple examples in the book, learn the concepts taught by those examples and, when you know them, move on to the next topic.

Reading and participating in your many threads (and our PMs) shows that you unfortunately haven't learned the lessons that many here have tried to teach including start simple, stay focused, and master concepts before moving on to something else. That's important because complex concepts build upon simple ones and if you haven't mastered the simple ones any hope of understanding more complex concepts will end in failure. Yesterday it was receiving GPS strings on a UART, today it's a survey of software design methods. Tomorrow is anybody's guess.

None of us are trying to scold you here but you continue to have trouble in your programming efforts because of the way you approach problems. As you've been told many times by many experienced members here and elsewhere, until you change your approach you'll continue to have problems.

Just trying to help you.
 

spinnaker

Joined Oct 29, 2009
7,830
How is it possible to graduate from any engineering school today and not at least have a very basic knowledge of OOP? I would think even the most basic engineering curriculum would have at least some Java or C++ programming.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
Reading and participating in your many threads (and our PMs) shows that you unfortunately haven't learned the lessons that many here have tried to teach including start simple, stay focused, and master concepts before moving on to something else. .
I am working together on both C and embedded C programming. I am doing practice writing code on PC. I am practicing to solve some tough C examples. I don't say I am good at programming but I can say I am doing batter the before. I think I am not too bad who can't start to write embedded programming. As you can see I have been writing embedded program for LED, Switch, Push button, DC Motor, LCD, IR sensor.. I know it's not enough. I posted GPS thread 16 day's ago and I was asking about the GPS and working of It. I had knowledge of Uart and interrupt program I knew both are important for GPS interfacing so I tried to understand about GPS programming. I have some issues there I though I should try myself. defiantly I will come back on that thread

How is it possible to graduate from any engineering school today and not at least have a very basic knowledge of OOP? I would think even the most basic engineering curriculum would have at least some Java or C++ programming.
You can blame me that I was not serious or bad education system. It's up to you. I can not change what has been happened but I can try my best for improving skills and I am doing it.
 
Last edited:

WBahn

Joined Mar 31, 2012
29,976
How is it possible to graduate from any engineering school today and not at least have a very basic knowledge of OOP? I would think even the most basic engineering curriculum would have at least some Java or C++ programming.
I doubt there are many engineering curricula that don't require programming to some degree, but I imagine there are still quite a few around that don't require object-oriented programming.
 

WBahn

Joined Mar 31, 2012
29,976
Yes, I am doing this. I am studying book for c programming. at the starting of book on the 4th page. there is description about structured and object oriented programming but there is not much description. I spend some time on google and I found the bunch of materials but I did not understand it the real meaning.
Once again I would recommend to you the Nand2Tetris project. You will learn how objects are implemented and how the functions that operate on them are accessed from the object.

As has already been pointed out, structured programming and object-oriented programming are not two different alternative. Structured program is simply programming using a small set of well-defined control structures -- namely sequences, selections, and iteration constructs. The big thing is that you do NOT use goto statements for controlling the logical flow of your program. Object-oriented programming is just a further refinement on structured programming in which access to much of the code is restricted so that it is difficult to call functions from places where calls to those functions is all but guaranteed to be a logical error and to make it difficult for functions to act on data other than the right kind of data for that function. Through discipline you can write code that is very object-oriented-like even in a language that is not (such as C) and you can write programs that are structured-like even in a language that is not (such as assembly). Since this is transitive, that means that you can write object-oriented-like programs even in non-structured languages. What structured languages do is make it easy to write structured programs and hard to write non-structured programs. What object-oriented languages do is make it easy to write object-oriented programs and hard to write non-object-oriented programs.
 

nsaspook

Joined Aug 27, 2009
13,079
When most people hear OOP they think about computer languages or programming but the motivation of using OOP in a project is something else. It's a method of analytical reasoning central to engineering in general.

 

spinnaker

Joined Oct 29, 2009
7,830
You can blame me that I was not serious or bad education system. It's up to you. I can not change what has been happened but I can try my best for improving skills and I am doing it.
Why don't you go back to school then? Here we can "monitor" a class. You get the same thing all of the other class members get but there is no degree. It can be cheaper than a degreed course.
 

JohnInTX

Joined Jun 26, 2012
4,787
Why don't you go back to school then? Here we can "monitor" a class. You get the same thing all of the other class members get but there is no degree. It can be cheaper than a degreed course.
That’s a really good idea. You might not be able to audit courses at a local university but check out Acedemic Earth. They link to courses from places lice Stanford and MIT among others. Free.
https://en.wikipedia.org/wiki/Academic_Earth
 

Brian Griffin

Joined May 17, 2013
64
I doubt there are many engineering curricula that don't require programming to some degree, but I imagine there are still quite a few around that don't require object-oriented programming.
What I remembered during my college days, the C++ course I had was only half-semester. It went together with the Autocad class, which was the other half of the semester. Not all engineering syllabuses and schools include OOP inside, but I wish it was though.

In where I stay, there are quite limited schools teaching C/C++ or Java. Most of them are about HTML or some webpage programming course.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
Once again I would recommend to you the Nand2Tetris project. .
I have read all those projects on this site http://nand2tetris.org/course.php There have been explained in very simple way to understand the basic of computer architecture but there is no information for c language. I am not become expert but I am trying my best

Why don't you go back to school then? Here we can "monitor" a class. You get the same thing all of the other class members get but there is no degree. It can be cheaper than a degreed course.
I have some financial issues. I took the three month's class for embedded system but I didn't learn more because I had many doubt during the 2 hour's lecture. There was 60 student in class There was few time to ask questions So I could clear only few doubt's.

The best thing is that I have not given up. I have confidence in myself that I can learn programming. I like to read about embedded system and programming. I am doing my best at every day. I am not saying that I am victim I know I have done so many mistakes but I have learned a lot from mistake. I don't know what you think about my performance but I am feeling good because I think I am batter then before. I just need a good planning.I am not be afraid to work hard. My mistake is that I do not ask the right questions at the right time. I think I should work more on this.
 
Last edited:
Top