Understanding Abstraction by parameterization and specification

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

31 Replies - 1339 Views - Last Post: 14 November 2013 - 12:08 PM

#1 feoleb  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 61
  • Joined: 24-November 12

Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 11:31 AM

Hello,

I'm wondering if anyone can provide me with a definition that I might be able to understand. I have studied the basics of java and c++, but this book I'm supposed to be learning from doesn't make much sense to me.

Book definition:
Abstraction by parameterization abstracts from the identity of the data by replacing them with parameters. It generalizes modules so that they can be used in more situations.

I'm not sure what 'abstracts from the identity' means and I'm not sure what kind of parameters we're talking about here.

Book definition:
Abstraction by specification abstracts from the implementation details (how the module is implemented) to the behavior users can depend on (what the module does). It isolates modules from one another's implementations; we require only that a module's implementation supports the behavior being relied on.

I just do not understand what that means at all. Would someone be able to explain in English?

Is This A Good Question/Topic? 0
  • +

Replies To: Understanding Abstraction by parameterization and specification

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9267
  • View blog
  • Posts: 34,761
  • Joined: 12-June 08

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 12:03 PM

Have you taken a chance at looking other views on the topic?

http://www.cs.cornel...ures/lec06.html
http://people.clarks...ractionSpec.pdf
http://www.cs.colost...Abstraction.pdf

Quote

Book definition:
Abstraction by parameterization abstracts from the identity of the data by replacing them with parameters. It generalizes modules so that they can be used in more situations.

I'm not sure what 'abstracts from the identity' means and I'm not sure what kind of parameters we're talking about here.

It means you don't care the literal specifics of the data coming in, but worry just about there being some data there and the type.

Example:
Function Derp(Int32 x ) As Int32
        Return x * 4
End Function


I don't care what 'x' is.. It could be 1, one million, -24, etc... I just care that I know an integer is coming in and I'll be multiplying it by 4. The ACTUAL number does not play a factor in my logic that I need Derp to return an integer times four.


Quote

Book definition:
Abstraction by specification abstracts from the implementation details (how the module is implemented) to the behavior users can depend on (what the module does). It isolates modules from one another's implementations; we require only that a module's implementation supports the behavior being relied on.

I just do not understand what that means at all. Would someone be able to explain in English?


Taking my example above Derp can be called by other methods, classes, objects, - or where ever.. and those calling it do not need to know that I just did X*4, but what they do care about is the output. BAsic 'black box' hand waving.. If I am calling this I just need to furnish a value and know that the output is that value times four. I could care less if it was done by X + X + X + X or X*4 or X*5-X...
Was This Post Helpful? 0
  • +
  • -

#3 feoleb  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 61
  • Joined: 24-November 12

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 12:21 PM

Quote

It means you don't care the literal specifics of the data coming in, but worry just about there being some data there and the type.

Example:
1
Function Derp(Int32 x ) As Int32
2
Return x * 4
3
End Function


I don't care what 'x' is.. It could be 1, one million, -24, etc... I just care that I know an integer is coming in and I'll be multiplying it by 4. The ACTUAL number does not play a factor in my logic that I need Derp to return an integer times four.


I don't really understand what your example is showing. It's a function. I understand how the function works. I'm not sure how that explains abstraction though. Also I looked over the links you sent me. I guess it means that abstraction is supposed to make things simpler. I dunno.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9267
  • View blog
  • Posts: 34,761
  • Joined: 12-June 08

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 12:25 PM

Quote

I don't really understand what your example is showing. It's a function. I understand how the function works. I'm not sure how that explains abstraction though

For which part? The first or the second?

Quote

I understand how the function works.

Congrats.. functions are abstractions. Variables are abstractions.
Was This Post Helpful? 0
  • +
  • -

#5 feoleb  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 61
  • Joined: 24-November 12

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 12:30 PM

The abstraction by parameterization. I guess the code was for that definition right?
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10595
  • View blog
  • Posts: 39,244
  • Joined: 27-December 08

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 12:31 PM

Moved to Software Development.
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9267
  • View blog
  • Posts: 34,761
  • Joined: 12-June 08

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 12:36 PM

Quote

The abstraction by parameterization. I guess the code was for that definition right?

What?


The parameters are variables.. variables are abstraction.

My function didn't say "Derp(3) as int32".. or "Derp(-45648743) as int32".. no.. it said "Derp(Int32 x ) As Int32"... Int32 X. That means I do not need to make up a function for every number possible to hard code it all.. I can use a variable and have one function.
Was This Post Helpful? 0
  • +
  • -

#8 feoleb  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 61
  • Joined: 24-November 12

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 01:05 PM

View Postmodi123_1, on 12 November 2013 - 12:36 PM, said:

Quote

The abstraction by parameterization. I guess the code was for that definition right?

What?


The parameters are variables.. variables are abstraction.

My function didn't say "Derp(3) as int32".. or "Derp(-45648743) as int32".. no.. it said "Derp(Int32 x ) As Int32"... Int32 X. That means I do not need to make up a function for every number possible to hard code it all.. I can use a variable and have one function.


So if variables are abstraction, then what is abstraction by parameterization?
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9267
  • View blog
  • Posts: 34,761
  • Joined: 12-June 08

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 01:32 PM

... by having parameters in a function you create abstraction. The alternative would have every conceivable number hardcoded in the function to start out with.
Was This Post Helpful? 1
  • +
  • -

#10 feoleb  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 61
  • Joined: 24-November 12

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 01:47 PM

View Postmodi123_1, on 12 November 2013 - 01:32 PM, said:

... by having parameters in a function you create abstraction. The alternative would have every conceivable number hardcoded in the function to start out with.


So that means the variable is actually the parameter, and that is what allows us to simplify the program? And is it only variables that are parameters or can it be other things too?
Was This Post Helpful? 0
  • +
  • -

#11 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9267
  • View blog
  • Posts: 34,761
  • Joined: 12-June 08

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 01:56 PM

Quote

So that means the variable is actually the parameter

What variables?

Parameters - to a function - are just like variables in their use.. they just help channel the caller into requiring specific values in.


Quote

and that is what allows us to simplify the program?

The very existence/ use of a parameter means I can use any value (that is valid for a datatype) instead of hardcoding every permutation of input values.

Again - back to my example. If I wanted to have a function/method that returned a number times four.. if I did not have a parameter then I would have to enumerate EVERY possible case in their own functions..

    Function Derp1() As Int32
        Return 1 * 4
    End Function
    Function Derp2() As Int32
        Return 2 * 4
    End Function
    Function Derp3() As Int32
        Return 3 * 4
    End Function
    ... 
    Function Derp99() As Int32
        Return 99 * 4
    End Function


With a parameter I can only make one function.

    Function Derp(ByVal x As Int32) As Int32
        Return x * 4
    End Function



Instead of explicitly writing out every freaking case I can abstract the concept and use a parameter.



Quote

And is it only variables that are parameters or can it be other things too?

Ah.. what the heck does this even mean?
Was This Post Helpful? 0
  • +
  • -

#12 feoleb  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 61
  • Joined: 24-November 12

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 02:04 PM

View Postmodi123_1, on 12 November 2013 - 01:56 PM, said:

Quote

So that means the variable is actually the parameter

What variables?

Parameters - to a function - are just like variables in their use.. they just help channel the caller into requiring specific values in.


Quote

and that is what allows us to simplify the program?

The very existence/ use of a parameter means I can use any value (that is valid for a datatype) instead of hardcoding every permutation of input values.

Again - back to my example. If I wanted to have a function/method that returned a number times four.. if I did not have a parameter then I would have to enumerate EVERY possible case in their own functions..

    Function Derp1() As Int32
        Return 1 * 4
    End Function
    Function Derp2() As Int32
        Return 2 * 4
    End Function
    Function Derp3() As Int32
        Return 3 * 4
    End Function
    ... 
    Function Derp99() As Int32
        Return 99 * 4
    End Function


With a parameter I can only make one function.

    Function Derp(ByVal x As Int32) As Int32
        Return x * 4
    End Function



Instead of explicitly writing out every freaking case I can abstract the concept and use a parameter.



Quote

And is it only variables that are parameters or can it be other things too?

Ah.. what the heck does this even mean?


I understand it's bad to write out all possible variables. Still not really clear on abstraction by parameterization though.
Was This Post Helpful? 0
  • +
  • -

#13 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9267
  • View blog
  • Posts: 34,761
  • Joined: 12-June 08

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 02:11 PM

Quote

I understand it's bad to write out all possible variables. Still not really clear on abstraction by parameterization though.


That's the whole f'ing point.. instead of writing out each and every numerical case for all the numbers in the entire range of int32 I can just wave my hand and say "no.. I will abstract the numbers into a parameter.. That means I can still have my program compile against this parameter and not worry about writing a function for every number between -2,147,483,648 to 2,147,483,647.

That is abstraction. Seriously it's not that hard. The abstraction is I do not give a rat's ass about the ACTUAL number coming in (else I would have to have a method for every number between -2,147,483,648 to 2,147,483,647), but I do care that it is a number.. and I know how to do math against numbers..
Was This Post Helpful? 0
  • +
  • -

#14 feoleb  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 61
  • Joined: 24-November 12

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 02:29 PM

View Postmodi123_1, on 12 November 2013 - 02:11 PM, said:

Quote

I understand it's bad to write out all possible variables. Still not really clear on abstraction by parameterization though.


That's the whole f'ing point.. instead of writing out each and every numerical case for all the numbers in the entire range of int32 I can just wave my hand and say "no.. I will abstract the numbers into a parameter.. That means I can still have my program compile against this parameter and not worry about writing a function for every number between -2,147,483,648 to 2,147,483,647.

That is abstraction. Seriously it's not that hard. The abstraction is I do not give a rat's ass about the ACTUAL number coming in (else I would have to have a method for every number between -2,147,483,648 to 2,147,483,647), but I do care that it is a number.. and I know how to do math against numbers..


I understand that you don't want to have to write everything out every time. You have explained that again but again I'll say, I do understand that part. It's what abstraction by parameterization means, that I'm concerned with. Like does it only apply to that example? Does it only have to do with turning larger amounts of information into smaller ones like catagories or variables or whatever?
Was This Post Helpful? 0
  • +
  • -

#15 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9267
  • View blog
  • Posts: 34,761
  • Joined: 12-June 08

Re: Understanding Abstraction by parameterization and specification

Posted 12 November 2013 - 02:34 PM

Quote

It's what abstraction by parameterization means, that I'm concerned with.

... are you trolling me or something?


Abstracting - observing similar conditions, making a pattern, and applying that pattern. In this case being less concerned about the actual, literal, values coming in but just their datatype and having a 'stand in' be there to represent any and all possible input for a given data type.


Quote

Like does it only apply to that example?

Yes.. 'abstraction by parametrization' *ONLY* works in that one narrow example I whipped up. OF COURSE it is not isolated to that example, but that sure as hell drives home the benefits of why dealing with a stand-in object (and not caring about the actual, literal, value) are great.

Quote

Does it only have to do with turning larger amounts of information into smaller ones like catagories or variables or whatever?

I have no idea what you are asking.. simply put you 'abstract by parameters' when you use a parameter in place of a hard coded value.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3