Author Topic: Code/Interface Seperation  (Read 7594 times)

0 Members and 1 Guest are viewing this topic.

Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
Code/Interface Seperation
« on: September 22, 2005, 09:33:59 pm »
Alright, I have a question for all you people who know what your doing...

... Do you believe in separating your code from your interface?

By this I mean a series of classes that make functions more and more specific.. As in a PacketSocket class to a RawData socket, to a bnetsocket, or a ShellSocket to a ShellFunctionClass. (When I say class, I mean a class. Not a fake VB module.) I do because I like reusing code, and I quickly make a change at the base of similar classes without changing each one...

Others argue that coding "right in the UI" is easier, faster, and better because you can customize your code... I would rather have a "Whisper" event then have to parse the packet right there in the UI..


Thoughts? Comments? Ideas? Questions? Sandwiches?
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Code/Interface Seperation
« Reply #1 on: September 22, 2005, 09:36:28 pm »
Alright, I have a question for all you people who know what your doing...

... Do you believe in separating your code from your interface?

By this I mean a series of classes that make functions more and more specific.. As in a PacketSocket class to a RawData socket, to a bnetsocket, or a ShellSocket to a ShellFunctionClass. (When I say class, I mean a class. Not a fake VB module.) I do because I like reusing code, and I quickly make a change at the base of similar classes without changing each one...

Others argue that coding "right in the UI" is easier, faster, and better because you can customize your code... I would rather have a "Whisper" event then have to parse the packet right there in the UI..

Organization is Godly.



Sandwiches?
Great idea!  I'll be back in a few minutes.

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: Code/Interface Seperation
« Reply #2 on: September 22, 2005, 09:42:31 pm »
VB has classes.  Don't assume things.

Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
Re: Code/Interface Seperation
« Reply #3 on: September 22, 2005, 09:45:28 pm »
I knew that... I met that using modules did not count as separation.
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Code/Interface Seperation
« Reply #4 on: September 22, 2005, 11:23:12 pm »
VB has classes.  Don't assume things.

VB has classes, but not class, and is not object-oriented.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Code/Interface Seperation
« Reply #5 on: September 24, 2005, 10:57:06 am »
Alright, I have a question for all you people who know what your doing...

... Do you believe in separating your code from your interface?

By this I mean a series of classes that make functions more and more specific.. As in a PacketSocket class to a RawData socket, to a bnetsocket, or a ShellSocket to a ShellFunctionClass. (When I say class, I mean a class. Not a fake VB module.) I do because I like reusing code, and I quickly make a change at the base of similar classes without changing each one...

Others argue that coding "right in the UI" is easier, faster, and better because you can customize your code... I would rather have a "Whisper" event then have to parse the packet right there in the UI..


Thoughts? Comments? Ideas? Questions? Sandwiches?

Well coding (in VB) I seperate all code which is reuseable into a class module and static code as in code that does things that need no abstraction (like conversions, and other simple things) go in regular modules.

Now in PHP I make all of my bulk functions in a single file or if I'm programming OOP I make them a bunch of classes which extend the core. To display the UI it would pass through the template handler then the feed from each page which would then write to the page itself.

One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Code/Interface Seperation
« Reply #6 on: September 24, 2005, 01:22:59 pm »
Now in PHP I make all of my bulk functions in a single file or if I'm programming OOP I make them a bunch of classes which extend the core. To display the UI it would pass through the template handler then the feed from each page which would then write to the page itself.
That's a rather common technique.

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Code/Interface Seperation
« Reply #7 on: September 24, 2005, 05:22:57 pm »
Separating interface and processing is one of the basic things you learn that you have to do if you want to program anything that's a reasonable size.  Visual Basic is very hard to do that in, it greatly encourages mixing up interface/processing. 

When you program a project, think about this: if you wanted to change it to a console interface, or remote interface, or a different graphical interface, how much code would you be replacing? If you would have to replace code that has nothing to do with the interface, then you have a problem. 

Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
Re: Code/Interface Seperation
« Reply #8 on: September 24, 2005, 05:34:06 pm »
Separating interface and processing is one of the basic things you learn that you have to do if you want to program anything that's a reasonable size.  Visual Basic is very hard to do that in, it greatly encourages mixing up interface/processing. 

When you program a project, think about this: if you wanted to change it to a console interface, or remote interface, or a different graphical interface, how much code would you be replacing? If you would have to replace code that has nothing to do with the interface, then you have a problem. 

Amen.
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Code/Interface Seperation
« Reply #9 on: September 26, 2005, 03:21:29 pm »
Exactly, having all of the essential code wrapped around other functions which the UI can call fourth would make switching whatever UI you use a snap. :)
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Tuberload

  • Neophyte
  • x86
  • Hero Member
  • *****
  • Posts: 530
    • View Profile
Re: Code/Interface Seperation
« Reply #10 on: September 26, 2005, 03:30:50 pm »
And Object Oriented Programming was born.
I am prepared to be ridiculed for what I believe, are you?

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Code/Interface Seperation
« Reply #11 on: September 26, 2005, 03:34:13 pm »
Hello world.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
Re: Code/Interface Seperation
« Reply #12 on: September 27, 2005, 07:16:46 pm »

Neither my tech teacher or I think that putting code into a module counts as UI separation.

It really ticks me off when I look at converted VB source code and they have all of there controls (PushButtons, Sockets, etc.) "forward" to a module, and then that module calls that socket DIRECTLY.

I was talking to the guy that wrote MikeBot, first complaining that there where swear words in his comments, and we started discussing programming. His idea of UI and code separation was to have modules do all the "processing".

NO NO NO NO!

Correct me if I am wrong, but to correct way to do things involves a class hierarchy. For example, you would have a class called PacketSocket, which would use other classes such as PacketBuilder and PacketBuffer to pass a packet in an event. Then, you could create 2 sub-classes, rawbnetsocket, and rawbnlssocket. There, you handle all the connection information. For example, in the BNLS socket, you would have a method called "SendCDKey" which would trigger an event that included (or just returned) the hashed CDKey. Then you could sub-class rawbnetsocket to have methods such as Whisper, SayText, etc.

So many people use the module method, I figure there has got to be a reason, but I just can't find one!
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: Code/Interface Seperation
« Reply #13 on: September 28, 2005, 03:55:52 pm »
Exactly. Have a core bot class which then invokes independant socket classes and stuff.
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: Code/Interface Seperation
« Reply #14 on: September 29, 2005, 06:59:46 pm »
In my most recent bot (not released or even working quite yet), I've gone through painful lengths to class just about everything.  I even control the form from a main class.  I've broken it down a lot farther than I ever have, but I doubt I will even finish this thing.