any of guys want to have a little fun educating me on an engineering concept? (1 Viewer)

vba_php

Banned
Joined
Oct 6, 2019
Messages
1,974
any of you guys want to have a little fun educating me on an engineering concept?

I have to talk to a rather intelligent engineer (probably *too* smart, really) next week regarding quite a few concepts that are apparently being heavily utilized in the private business sector nowadays. Most of these concepts I have no issue with explaining them to someone more experienced than myself, however there are a couple that throw me a little off base in terms of "head wrapping ability". I'm going to be battered with questions in all of the following areas:

Object Oriented Programming
• Abstraction
• Inheritance
• Polymorphism
• Encapsulation

Java and C#
• Syntax
• Data Types
• Conditional Statements
• Loops
• Classes
• Interfaces
• Abstract Classes
• Exceptions
• Collections

SQL
• Structure
• Relationships
• Normalization
• Syntax
• DDL
• Constraints
• DML
• Joins
• Unions

HTML
• Elements
• Attributes
• Forms
• HTTP

CSS
• Selectors
• Box Model
• Styling Attributes

JavaScript
• Syntax
• Data Types
• Functions
• Objects
• DOM Manipulation
• Event Management

Most of this is not a problem, however I would like some input from you professionals on Abstraction, Polymorphism and Encapsulation. The latter is pretty easy to understand for me, as a lot of the explanations on-line are pretty good in terms of relating it in plain English. However, Abstraction and Polymorph did *not* yield any results in plain English. Would anyone of you guys here want to offer your take on the purpose and operation of those 2 items?
 
Last edited:

MajP

Access MVP
Joined
May 21, 2018
Messages
2,285
Abstraction is pretty easy. We usually think of this in OOP but all code does this in some way. You hide the internal workings from the user. The users does not need to know how to build the watch, just how to use it. Almost all classes have public properties and methods, and the user does not need to know how these work just how to use them. Most of the time the class variables are private so are not exposed but they can be accessed by the properties (often referred to as accessors for that reason).

Polymorphism: One name many forms

Careful with this one, because sometimes the definitions are not complete.

There is compile time polymorphism which is done by method overloading.
Imagine you have 2 methods with the same name, but different arguments
(cannot be done in vba, but demoed here with pretende vba structure).

Code:
public Function Combine(number1 as long, number2 as long) as long
  combine = number1 + number2
end function
Code:
public Function Combine(string1 as string, string2 as string) as sting
  combine = string1 & " " & string2
end function
At compile time the compiler will determine which method to call based on
number and types of arguments you pass. so

Code:
Dim x as string
Dim y as long
x = combine("A","b")
y = combine(1,2)
Run time polymorphism deals with inheritance, interfaces, and abstract
classes.

Imagine you built a class Robot with basic properties and methods that a
robot does and has. Then you subclass two new classes SubmarineRobot and AirRobot. These classes will inherit all the properties and methods of Robot without you having to rewrite them in your subclass. Now you can add additional methods and properties to the subclass that are unique to the sub classes. Also you can override the base class methods and properties if you would like specific ones for your subclass.

If the base Robot had a generic Move method, your subclasses would immediately get that method as well.

Code:
Public Sub Move(Velocity as double, Direction as double)
  'code here a basic move method
end sub
However if the generic Move does not make sense for your underwater and air robot then you can override this method in subclass. You write methods in the subclasses called Move but do something different.

in the AirRobot you may have something like

Code:
Public Sub Move(Velocity as double, Altitude as double, Direction as double)
overrides mybase.move
  'some flying code here
end sub
in the SubmarineRobot you may have something like

Code:
Public Sub Move(depth as double, Direction as double) overides mybase.move
  'some underwater code to move it
end sub

Code:
dim myAirRobot as Robot
dim mySubRobot as robot
set myAirRobot as new AirRobot
set mySubRobot as new submarineRobot

myAirRobot.move  ' at runtime determines it is an airRobot and flies it
mySubrobot.move  ' at runtime determines it is a submarine and swims it
 

vba_php

Banned
Joined
Oct 6, 2019
Messages
1,974
well your response completely caught me off guard, Maj. I was sure I wouldn't ever hear from you again after what you said to me here. Thank you so much for sharing your knowledge on the subject matter. I will review it thoroughly and post back if I have any trouble understanding it. :)
 

MajP

Access MVP
Joined
May 21, 2018
Messages
2,285
You of all the people should not be so thin skinned. You love spinning people up, you got to expect people to give it back to you once and a while.
 

vba_php

Banned
Joined
Oct 6, 2019
Messages
1,974
You love spinning people up
do you *really* believe that? All of you guys here still have got the wrong picture. Other than giving Richard and Colin some $hit once in while, I don't purposely pull anyone else's chain. Unless you can point me to some examples that have slipped my mind?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom