12 Replies - 1377 Views - Last Post: 19 December 2016 - 11:01 PM

#1 Dialupp   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Am I lazy?

Posted 17 December 2016 - 06:44 PM

Hey guys so I have always struggled with programming I am a bit of a slow learner, when I first started programming I could barely watch a 3 minute video I would almost fall asleep no idea why, I think I was in a phase still deciding whether or not I liked programming. Months later it gotten alot better but I still face my original problem, which is understanding concepts. I can understand how it works, but don't understand WHY to use it or where it would be useful. Now I am learning about abstract classes and interfaces I don't get why use an abstract class over an interface, almost every link on google has the same answer, I need a really simple example but can't find one. Though I did find one for abstract classes when to use but couldn't for interfaces. This is the link I had and it helped quite a bit:

http://www.javacoffe...aq/faq0084.html

I wish there was something on interfaces something exactly like this.

In my own words don't know if this is correct but if I had to choose between an interface and abstract class I would say
"Use an abstract class when alot of members of classes are similar and use interface when they are not too similar" But I think this is wrong for the interface part.

Now you are wondering about the lazy part, what I meant by that is that I will keep trying to figure it out keep looking at links on google but would keep getting out of my chair walking around a bit frustrated can't figure it out.

Is This A Good Question/Topic? 0
  • +

Replies To: Am I lazy?

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 16480
  • View blog
  • Posts: 65,328
  • Joined: 12-June 08

Re: Am I lazy?

Posted 17 December 2016 - 06:50 PM

So what? Are you asking us if you have ADD?
Was This Post Helpful? 0
  • +
  • -

#3 Dialupp   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Re: Am I lazy?

Posted 17 December 2016 - 07:08 PM

I think I should of changed the title, but I guess is constantly getting up moving around lazy? I do have concentration problems, but this time I don't think it is one. If I could find a good enough example I would understand it.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 16480
  • View blog
  • Posts: 65,328
  • Joined: 12-June 08

Re: Am I lazy?

Posted 17 December 2016 - 07:13 PM

Lazy? Maybe. Wouldn't know about the rest of your life maneuvers.

Posted Image
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Am I lazy?

Posted 17 December 2016 - 07:18 PM

TL;DR
Was This Post Helpful? 0
  • +
  • -

#6 Dialupp   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Re: Am I lazy?

Posted 17 December 2016 - 09:29 PM

Seems like adhd 1.
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Am I lazy?

Posted 18 December 2016 - 03:22 AM

Start with the docs which has a good page.

Consider an abstract class "to share code among several closely related classes".

Consider an interface for unrelated classes (and even classes that haven't been defined yet) that will exhibit common behaviours or traits. Comparable is a good example. Many objects need to be compared to each other; the mechanics of how this comparison is implemented is not of concern, it is simply that they can be compared that is significant.
Was This Post Helpful? 0
  • +
  • -

#8 Dialupp   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Re: Am I lazy?

Posted 18 December 2016 - 03:33 AM

Oh I was somewhat correct! Thanks man, it's more clear now.

This post has been edited by andrewsw: 18 December 2016 - 03:34 AM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#9 Dialupp   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Re: Am I lazy?

Posted 18 December 2016 - 03:42 AM

Why would we care about implementation in any scenario? Since we are coding the program we know how its mechanics work.
Was This Post Helpful? 0
  • +
  • -

#10 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Am I lazy?

Posted 18 December 2016 - 04:11 AM

Quote

Why would we care about implementation in any scenario?

As an application grows the goal of object-oriented programming is that we won't care about implementation details. We will use the public interface (the methods and properties) of classes that we (or someone) built earlier. We just need to know their method signatures, and expected output. See Encapsulation.

Quote

Since we are coding the program we know how its mechanics work.

This assumes that you are the only person creating the application; that it is very small and you work on it every day so that you are always in full knowledge of every aspect of it. This is never the case. Just a few days away from it and you will forget things.

The goal of object-oriented programming is to create reusable, modular and maintainable code, and specifically that a person (any person) does NOT have to be intimately acquainted with an application's (or library's) internals to be able to work with it or add to it.
Was This Post Helpful? 0
  • +
  • -

#11 Dialupp   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Re: Am I lazy?

Posted 18 December 2016 - 12:40 PM

Ah ok. Hey man I wanted to ask you something, doing more research this is what I come up with. Abstract class common functionality(methods) When we say common is it say for example in the abstract class we have a non abstract method called message(); and it prints "hi" or something, do we use the abstract class if we want the other classes to call the EXACT same thing, hence printing the same message. And use interface if not common methods? Like say we have in interface a method called grades, would we use interface if we wanted to have 2 grades versions, one with a scoring system of A,B,C,D,E,F and one of just out of 100?

Obviously the classes inheriting the interface they will both have the message(); method available but does the word "functionality" refer to the code within the brackets or the output, or both? Thanks.
Was This Post Helpful? 0
  • +
  • -

#12 Dialupp   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 210
  • Joined: 31-October 16

Re: Am I lazy?

Posted 19 December 2016 - 06:10 PM

bump
Was This Post Helpful? -2
  • +
  • -

#13 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 16480
  • View blog
  • Posts: 65,328
  • Joined: 12-June 08

Re: Am I lazy?

Posted 19 December 2016 - 11:01 PM

Let's not bump the topic too quickly this is still a volunteer forum. :^:

Interfaces help communicate between two dissimilar classes..
Abstract is more modeling similar classes..

Example:
http://www.programme...abstract-class/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1