Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,363 members, 7,808,265 topics. Date: Thursday, 25 April 2024 at 09:35 AM

Understanding Programming-(lesson 1- Abstraction Of Objects) - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Understanding Programming-(lesson 1- Abstraction Of Objects) (974 Views)

Understanding The Wordpress Theme Template Hierarchy – Tutsplus / [b]Any body with a simple understanding of open source?[/b] / Mediocrity As A Result Of Not Understanding Programming Concepts (2) (3) (4)

(1) (Reply) (Go Down)

Understanding Programming-(lesson 1- Abstraction Of Objects) by seunthomas: 9:58am On Jun 20, 2015
Hello NL, i decided to share my views and my experience on software development. I have been coding for a while and have worked on many projects. Some projects worked fine while others not so fine. Most important lesson i have gotten so far is that programming is a lifelong process. You get better every day. I will start today with an introduction into the concept of an object. But first of all lets start with the rudimentary foundation. A programming language in most cases consist of a runtime(or execution environment) which is the part that takes your code(source code) and converts it to a machine understandable format. A machine(computer,laptop,phone) is actually a very dumb device. It cant do anything on its own. It requires a human to give it the necessary instruction to do something meaningful. Although their are advances in software development that have brought in work such as an intelligent machine(AI,deep learning) but they are not totally autonomous and still require a human. The Other core part of a programming language is the language itself. By the language we mean PHP,Javascript,Java,Assembly,Python,C/C++,C# etc. The language of choice for any programming task depends on the capability of the language as well as the design ideology of the language author. Some languages like Java,C/C++,Python,C# etc are very robust. They can actually work in massive environments. While others may be limited or require extra work to make them work in such environments. I can rightly say that "Not all languages where created equal". Another important note is that machines don't understand code. Machines can only think in digits 1,0,one zero. So basically your programming runtime takes your source code and does the necessary conversion for you.

Now lets go into coding. What is an Object? An object is just a way of abstracting the real from the unreal. The human mind can understand things when they appear more physical or realistic than when they are totally abstract.
Thats why we use objects.
A basic object in some languages would look like this:
Python:

class Person:
def __init__(self,name,age,gender):
self.name=name
self.age=age
self.gender=gender
def setName(self,name):
self.name=name
def getName(self):
return self.name

Java:

class Person(){
String name;
String gender:
int age;
public Person(){

}
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}

}
Basically what we have done is create an object. An object is our way of encapsulating something. We use objects in many cases to hide the real underlying fact about a piece of code. For example we have modeled all the data about a Person in our object. So our object person has a name and an age.

Comment and i will continue on this lesson.

2 Likes

Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by Nobody: 10:34am On Jun 20, 2015
Pls continue. I want to learn python. Have some java basics
Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by seribroo56(m): 10:47am On Jun 20, 2015
choose4me:
Pls continue. I want to learn python. Have some java basics
if you are using a smart phone you can download an app called coursera. And learn phyton... It's a 11wks training and they are in week 3
Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by menesheh(m): 10:49am On Jun 20, 2015
My interested laid
Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by seunthomas: 12:55pm On Jun 20, 2015
The idea behind objects is the same thing in every language. What we do with objects is to represent our application in a modular and encapsulated way. Take for example a banking application. We can have the following types of objects:
a. Customer
b. Cashier
c. User
d. Manager
e. BankCommission
f. Transactions
g. Accounts

a simple representation of the Customer object and explanation
Python:
Class Customer:
def __init__(self,firstname,lastname):
self.firstname=firstname
self.lastname=lastname
With this piece of code what we have done is created small part of a customer object. To create an object in most languages(php,python,Java,c#) we use a reserved word called Class. If you dont know what a reserved word is you need to do more research(Reserved words are words that are reserved exclusively for the use by the programming language). The statement
Python
class Customer:
Java
class Customer{}
c#
class Customer{}
php
class Customer{}
This is used to create the base template for our Customer object.

1 Like

Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by seunthomas: 1:08pm On Jun 20, 2015
Next we need to put some flesh in out Customer object.
PLEASE NOTE THAT WHEN WRITING PYTHON CODE YOU MUST INDENT YOUR CODE PROPERLY.
JAVA is a case-sensitive language
Python:
class Customer:
#our constructor
def __init__(self,firstname,lastname):
self.firstname=firstname
self.lastname = lastname

Java
class Customer{
//Java explicitly requires forward declaration of all variable type;
String firstname;
String lastname;
//our constructor
public Customer(String firstname,String lastname){
this.firstname=firstname;
this.lastname=lastname;
}
}

PHP
class Customer{

$firstname="";
$lastname="";
//our constructor
public Customer($firstname,$lastname){
$this->firstname=$firstname;
$this->lastname=$lastname;
}
}

C#

class Customer{
//C# explicitly requires forward declaration of all variable type;
string firstname;
string lastname;
//our constructor
public Customer(string firstname,string lastname){
this.firstname=firstname;
this.lastname=lastname;
}
}

1 Like

Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by seunthomas: 1:11pm On Jun 20, 2015
Some important notes. For our Customer object, we created a constructor. When creating objects, we may use our constructor to pass parameters to our object variable. This is a clean way of sending data to our objects. Most important to know is that objects are closed systems. One of the ways to inject data into this system is by using constructors.
Lesson Note:
Everyone should create a simple object with any thing that occurs in our every day life. example: Car object,Student Object etc.
Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by pythondjango(m): 8:23am On Jun 30, 2015
I am keen for ur continuation on this thread pls.
Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by Nobody: 9:55am On Jun 30, 2015
Trollin'
Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by seunthomas: 12:08pm On Jun 30, 2015
I will continue it if am sure there is an interest. No point teaching what people dont want to know.
Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by jacob05(m): 1:42pm On Jun 30, 2015
Hmmm.... ***sits
Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by Jarchi(m): 4:31pm On Jun 30, 2015
Dhtml b like itz pay back time. La joke. Nice would love to learn more especiajly python,pls put examples cuz i have 3 books on python all saying rubbish got tired and opted out now back learning it fast with inventwithpython among odas with pygames.
Re: Understanding Programming-(lesson 1- Abstraction Of Objects) by Nobody: 7:00pm On Jun 30, 2015
*Spreads mat yakata*

1 Like

(1) (Reply)

How To Create Android App On Android Phone / Urgent! Any Non Hosted Nig Adsense For Sale Cal/add 08067116148 On Whatsap / ABAP Developer Intern At SAP SE

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 23
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.