473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

difference between imports-implements-inherits

Hi,

Can anybody explain me what's the difference between for example:
imports system.data
implements ICallbackEventHandler
inherits System.Web.UI.Page

Thanks
Bart
Jun 20 '06 #1
7 7147
Bart,
Can anybody explain me what's the difference between for example: imports system.data Tells that you use the namespace system.data, it has no other effects than
in the way you write your code.
implements ICallbackEventHandler Tells that ICallBackEventHandler is implemented and your code should be
about that conform this interface (contract)
inherits System.Web.UI.Page

Tells that you use this class (UI.Page) as base for your class, meaning that
all code which is in that class can be used by your class.

I hope this helps,

Cor
Jun 20 '06 #2
Hi Brat,

Well, I will try to explain it clearly:

imports: used at the very top of your code. It is used to import
already compiled libraries. It also simplifies your code. For example:

If you programming an application that requires alot of drawing, you
don't want to keep saying:
system.drawing.drawRectangle...
system.drawing.drawline...
system.drawing ....etc

you can import the system.drawing, and use the methods you need without
writing the full path. ie
drawRectangle...
drawline...
etc.

Inheritance:

Inheritance is a great feature in object oriented program (OOP). It
allows for code reuse and expansion. I remember in my programming
couses they always use the car class example. So, I am going to use it
again :)

Assume you have a class called car. Every car, has an engine,
transmission, make, model, four wheels. These properties are shared
among all cars. These are the basic car parts. You have 2door and 4
door cars. Lexury and convintional cars. SUVs, minvans ..etc. You don't
want to have one class that has all these information. And you don't
want to rewrite these info everytime a new type of car comes out. Let's
translate the above to code:

Class car
private Engine as string
private Transmission as string
private make as string
private model as string

public sub new (byval e as string, byval t as string, _
byval ml as string, byval mk as string)
Engine = e
transmission =t
make =ml
model =mk
end sub
end class

Now we have a sport car that is 2 doors, 2 seats, got a turbo.... we
dont want to retype every thing from the car class into the sport car
class. So we inherit it.

Class SportCar inherits car

private numDoors as integer
private numSeats as integer
private GotTurbo as boolean

public sub new (byval d as integer, byval s as integer, _
byval t as boolean, byval eng as string, byval trans as
string, _
byval make as string, byval model as string)
mybase (eng,trans,make,model)
numDoors = d
numSeats = s
GotTurbo = t

end sub
end class

The above is a very simple example it definitely get nastier.

Implement:
In OOP a class can't inherit from multiple class. Only one class. But
you can implement more than one interface. And a class can inherit
anther class and implement an interface at the same time. An interface
is a class but it only has signiture of methods or declaration of
properties. By implementing an interface, you are forcing the class to
define those methods/ properties

I hope I was able to clearify the difference. If you have more
questions let me know.

Cheers,
Ahmed
Bart_D wrote:
Hi,

Can anybody explain me what's the difference between for example:
imports system.data
implements ICallbackEventHandler
inherits System.Web.UI.Page

Thanks
Bart


Jun 20 '06 #3

Bart_D wrote:
Hi,

Can anybody explain me what's the difference between for example:
imports system.data
implements ICallbackEventHandler
inherits System.Web.UI.Page

Thanks
Bart


Imports:

A very much misnamed word. Should be "allow namespace" or the like.
Unfortunately, they named it after what it does, rather than how it is
used, and many programmers find that confusing.

Normally, when referring to a .NET item the fully-qualified name must
be used, starting with the top-most namespace and specifying each
level. Mentioning "Imports" will allow and name (or namespace) at that
level to be specified without the qualification of its parent.

For example, if i wanted to create a datatablemapping, normally i would
have to use the code:

Dim DTM As System.Data.Common.DataTableMapping

Using just:

Dim DTM As DataTableMapping

puts a blue line under DataTableMapping with the message "Type
'DataTableMapping' is not defined."

However, if i put "Imports System.Data.Common" at the top of the page,
it gives no error, because it now knows where to look for the
defintion.

In any case, placing it is not required. It is merely a matter of
covenience to the programmer and the code would work the same whether
it is fully-qualified, or Imports is used and it is not fully
qualified.

inherits is used when the code is creating an objects that inherits
from another class. This is a basic OOP concept.

B.

Jun 20 '06 #4
Thanks both for your explanations.
In fact i'm asking this because i made an application which i want to
partially convert with the ClientCallback technology. But its' not easy with
all those concept like 'implements', 'imports' etc ...

"Ahmed" <ah*******@gmail.com> wrote in message
news:11*********************@h76g2000cwa.googlegro ups.com...
Hi Brat,

Well, I will try to explain it clearly:

imports: used at the very top of your code. It is used to import
already compiled libraries. It also simplifies your code. For example:

If you programming an application that requires alot of drawing, you
don't want to keep saying:
system.drawing.drawRectangle...
system.drawing.drawline...
system.drawing ....etc

you can import the system.drawing, and use the methods you need without
writing the full path. ie
drawRectangle...
drawline...
etc.

Inheritance:

Inheritance is a great feature in object oriented program (OOP). It
allows for code reuse and expansion. I remember in my programming
couses they always use the car class example. So, I am going to use it
again :)

Assume you have a class called car. Every car, has an engine,
transmission, make, model, four wheels. These properties are shared
among all cars. These are the basic car parts. You have 2door and 4
door cars. Lexury and convintional cars. SUVs, minvans ..etc. You don't
want to have one class that has all these information. And you don't
want to rewrite these info everytime a new type of car comes out. Let's
translate the above to code:

Class car
private Engine as string
private Transmission as string
private make as string
private model as string

public sub new (byval e as string, byval t as string, _
byval ml as string, byval mk as string)
Engine = e
transmission =t
make =ml
model =mk
end sub
end class

Now we have a sport car that is 2 doors, 2 seats, got a turbo.... we
dont want to retype every thing from the car class into the sport car
class. So we inherit it.

Class SportCar inherits car

private numDoors as integer
private numSeats as integer
private GotTurbo as boolean

public sub new (byval d as integer, byval s as integer, _
byval t as boolean, byval eng as string, byval trans as
string, _
byval make as string, byval model as string)
mybase (eng,trans,make,model)
numDoors = d
numSeats = s
GotTurbo = t

end sub
end class

The above is a very simple example it definitely get nastier.

Implement:
In OOP a class can't inherit from multiple class. Only one class. But
you can implement more than one interface. And a class can inherit
anther class and implement an interface at the same time. An interface
is a class but it only has signiture of methods or declaration of
properties. By implementing an interface, you are forcing the class to
define those methods/ properties

I hope I was able to clearify the difference. If you have more
questions let me know.

Cheers,
Ahmed
Bart_D wrote:
Hi,

Can anybody explain me what's the difference between for example:
imports system.data
implements ICallbackEventHandler
inherits System.Web.UI.Page

Thanks
Bart

Jun 20 '06 #5
Brian,

Reading your message I thought for the first time: Import is the same as a
Global VB "With" where the first dot is than not needed.

:-)

Cor

"Brian Tkatch" <Ma***********@ThePentagon.com> schreef in bericht
news:11**********************@p79g2000cwp.googlegr oups.com...

Bart_D wrote:
Hi,

Can anybody explain me what's the difference between for example:
imports system.data
implements ICallbackEventHandler
inherits System.Web.UI.Page

Thanks
Bart


Imports:

A very much misnamed word. Should be "allow namespace" or the like.
Unfortunately, they named it after what it does, rather than how it is
used, and many programmers find that confusing.

Normally, when referring to a .NET item the fully-qualified name must
be used, starting with the top-most namespace and specifying each
level. Mentioning "Imports" will allow and name (or namespace) at that
level to be specified without the qualification of its parent.

For example, if i wanted to create a datatablemapping, normally i would
have to use the code:

Dim DTM As System.Data.Common.DataTableMapping

Using just:

Dim DTM As DataTableMapping

puts a blue line under DataTableMapping with the message "Type
'DataTableMapping' is not defined."

However, if i put "Imports System.Data.Common" at the top of the page,
it gives no error, because it now knows where to look for the
defintion.

In any case, placing it is not required. It is merely a matter of
covenience to the programmer and the code would work the same whether
it is fully-qualified, or Imports is used and it is not fully
qualified.

inherits is used when the code is creating an objects that inherits
from another class. This is a basic OOP concept.

B.

Jun 20 '06 #6
"Bart_D" <qs***@sscs.dc> schrieb:
Can anybody explain me what's the difference between for example:
imports system.data
implements ICallbackEventHandler
inherits System.Web.UI.Page


I suggest to check out the documentation on the keywords which can be opened
by pressing the F1 key.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 20 '06 #7

Cor Ligthert [MVP] wrote:
Brian,

Reading your message I thought for the first time: Import is the same as a
Global VB "With" where the first dot is than not needed.

:-)

Cor

"Brian Tkatch" <Ma***********@ThePentagon.com> schreef in bericht
news:11**********************@p79g2000cwp.googlegr oups.com...

Bart_D wrote:
Hi,

Can anybody explain me what's the difference between for example:
imports system.data
implements ICallbackEventHandler
inherits System.Web.UI.Page

Thanks
Bart


Imports:

A very much misnamed word. Should be "allow namespace" or the like.
Unfortunately, they named it after what it does, rather than how it is
used, and many programmers find that confusing.

Normally, when referring to a .NET item the fully-qualified name must
be used, starting with the top-most namespace and specifying each
level. Mentioning "Imports" will allow and name (or namespace) at that
level to be specified without the qualification of its parent.

For example, if i wanted to create a datatablemapping, normally i would
have to use the code:

Dim DTM As System.Data.Common.DataTableMapping

Using just:

Dim DTM As DataTableMapping

puts a blue line under DataTableMapping with the message "Type
'DataTableMapping' is not defined."

However, if i put "Imports System.Data.Common" at the top of the page,
it gives no error, because it now knows where to look for the
defintion.

In any case, placing it is not required. It is merely a matter of
covenience to the programmer and the code would work the same whether
it is fully-qualified, or Imports is used and it is not fully
qualified.

inherits is used when the code is creating an objects that inherits
from another class. This is a basic OOP concept.

B.


Granted. That is an intereted way to view it. :)

B.

Jun 21 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: max(01)* | last post by:
hi everybody. suppose that code-1.py imports code-2.py and code-3.py (because it uses names from both), and that code-2.py imports code-3.py. if python were c, code-1.c should only *include*...
2
by: Jon Gonzales | last post by:
Item #1: Project Reference > DLLClass1 Project Properties > Imports > Namespace.Namespace2 - In Code Behind: * Dim NewClass1 As New Class1 Item #2: Project Reference > DLLClass1 - In Code...
12
by: z. f. | last post by:
what's the difference between using the VB.NET function IIF or the c# operator ? VB.NET: a = iif ( b=c, d, e) C#: a= (b==c)?d:e TIA, z.
1
by: Alec MacLean | last post by:
Hi all, Can anyone tell me if there is any functional difference between declaring an Imports at the individual file level compared with doing it once on the project properties? ( - Other...
12
by: Keith Patrick | last post by:
Can someone tell me the difference in terms of actual implications using: namespace MyNamespace { using System; class MyClass {...} } vs. using System;
4
by: Martin Blais | last post by:
Hi I'm a tad confused over a problem involving cycles between packages. Assume the following sets of files:: driver.py a/__init__.py a/alice.py
6
by: douglass_davis | last post by:
Is the whole System namespace automatically imported?
23
by: Thorsten Kampe | last post by:
Okay, I hear you saying 'not another naming conventions thread'. I've read through Google and the 'naming conventions' threads were rather *spelling conventions* threads. I'm not interested...
5
by: kimiraikkonen | last post by:
Hello, I want to ask about "imports" statement. Some projects must be inserted with "imports xxxx" statements before beginning coding. But how do i know when to use or do i have to use "imports"...
1
by: tjhnson | last post by:
While working within a package...what is the 'best practice' way to do your imports. a/__init__.py a/one.py a/two.py a/b/__init__.py a/b/cat.py a/b/dog.py a/c/cow.py
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.