Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

MVC in Java

Name: Anonymous 2009-05-09 4:33

Hay guise. There are a bunch of sites out there that praise the MVC pattern up and down, but I can't seem to find anything but extremely trivial examples of it being put to use.

The deal is, I'm working on a Java project for school (it's a calendar.. how fun) and we're supposed to be utilizing MVC. To maintain a strict separation of view and controller, which is the usual problem spot for overlapping functionality, we simply moved all of the action and mouse listeners for the various windows and components into one huge controller class. To determine where events are coming from we either A) set action commands if it's an actionlistener, or B) name each component and have a bunch of if/else statements to see how we should handle the event.

This worked out ok in the beginning, but now it's just a huge clusterfuck. Everything would be so much easier if we could just use the traditional addActionListener(this) + implementing actionListenerfor each class or the good old addActionListener(new ActionListener(){... method, especially because a lot of the actual events don't even touch the backend, they just deal with modifying the view.

I guess the question I have is, how do you actually implement an MVC pattern in a real program? Should only the actions that will directly interface with the backend of the program be handled by the controller? There has to be a better way >:O

Name: Anonymous 2009-05-09 5:02

java
now you have 2 problems

Name: Anonymous 2009-05-09 5:53

addActionListenerModifyMoreStateLetTheseFunctionalFucksScratchTheirEyesOut()

Name: Anonymous 2009-05-09 6:02

Design Patterns Considered Harmful.

Name: Anonymous 2009-05-09 6:39

>>4
Design patterns exist to cover the logical deficiencies in current programming languages.

For example, the singleton is a pattern that is very helpful in multithreaded applications, particularly ones where you can't be sure or simply don't want to care which thread accesses the singleton first.

The design patterns themselves are not harmful, it is the programmers that use them indiscriminately and parrot that they are good without knowing why. Try "programmers considered harmful" next time.

Name: Anonymous 2009-05-09 8:43

>>5
Ok, Java programmers considered harmful then.

Name: Anonymous 2009-05-09 10:06

>>5
I don't like the Singleton pattern. Especially not in multithreaded scenarios. You have to watch out for all kinds of synchronization shit left and right. Take /prog/, for example.
Imagine a thread here, and think of two people posting in it at once! You'll never know which post will appear first, potentially ruining the the thread and an undefined number of other things, like your mother or your pet dog.

Name: Anonymous 2009-05-09 10:38

>>6
Anonymous approves.

>>7
I think the terms you're looking for are "locks" and "semaphores." Not synchronization. This isn't swimming. We're not on a boat. We didn't fuck a mermaid. If you're referring to pig-disgusting Java's synchronized methods, just stop. You obviously don't understand that design patterns are applicable to most languages.

And no, you don't have to "watch out" for using locks and semaphores. The singleton class should handle all the relevant operations to itself, including the locking mechanism. Remind me to keep you away from enterprise software.

Name: Anonymous 2009-05-09 11:49



                  /      \
               {       ヽ
         ____   ハ     }        This thread sucks
         ̄`>: : : : : ∨: : ー‐ --yz 、
         /: : : : : : : :/: : : : : : : : : : 、: :\
       /:_: : : : :/: : /: |: : : : : : : : : : :\: : ヽ
      / /// : :/: : :/:/:!: : :.:.|、: : : : : : : \: :.',
.      {/ // : :/: : :/_/:小:. :.:.|_ヽ__: : : : ヽ: l
        l/l : : !: : 7゙/ノ l| V:.|  \: : : :、 : : l: |
         |: :/|: :/:/  j|  ヽ|   \: : \: :!: \_
         |/ |;/l/x≡≡   |≡≡z.ハ: :.ヽl\: : : :\
        r┬z/:.:|           ∠─-ヘトr-く ̄ヽ :\
       r「「l {: : :\    ‐    ////「 { \ヽ:.:\ \ :\
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓

Name: Anonymous 2009-05-09 13:47

>>8
By synchronization, I am referring to two threads synchronizing their access to a shared resource, that is, only one accessing said resource at a time. It is usually implemented using locks, yes. Your point? And no, I was not specifically posting with Java in mind.

You obviously don't understand a whole lot about any programming language.

Name: Anonymous 2009-07-12 6:32

>>5
[blockquote]Failed THIS BULLSHIT f f THIS

Don't change these.
Name: Email:
Entire Thread Thread List