• (cs) in reply to hoodaticus
    hoodaticus:
    frits:
    C-Octothorpe:
    Who doesn't have a static "Util" class in their code base filled with various static "helper" methods like your example.
    Me.
    Me. Unless you count extension methods. I haven't yet met a dev who used extension methods to avoid OOP, though.

    Addendum (2011-09-28 16:02): In fact, the presence of a Util class is a huuuuuge warning sign that I'm gonna be teaching OOP in the near future.

    Simpson's mocking laugh: "HAA-ha!"

  • (cs) in reply to Nagesh
    Nagesh:
    Am I miss sumthing?
    You're missing a lot, actually...
  • (cs) in reply to talentless_newbie (too lazy to log in properly)
    talentless_newbie (too lazy to log in properly):
    Even if the original coder came from a purely procedural background (and I admit, I did, too), surely it should have occurred to them to wrap all of those into a structure, one would think.

    If you have 45 'out' parameters in one method, if you don't at least wonder whether there is a better way pass around and manipulate stuff, you should give up and go back to being an enduser.

    I had precisely this sort of discussion with a programmer who insisted on his nine, ten, eleven etc. parameter methods and constructors. His argument: "But that would mean writing yet another class just to pass these parameters around between these one, two, three .... goodness, six classes. Yet another class!" Putting on a patronising voice: "Don't you think this will make it just a tiny little bit overcomplicated?"

    And don't try refactoring the code he wrote or he would complain to the manager you'd "changed his code".

    Had one conversation "Did you change my code?!?!?" he screamed across the office. "Yes I did," I replied, "It had shitty nappies." ("nappies": UK English for "diapers".)

  • Matt H. (unregistered) in reply to TheSHEEEP
    TheSHEEEP:
    hoodaticus:
    Procedural coders should be banned from .NET development.

    They should be banned from pretty much anything. Just to be sure.

    Except crochet.

    Because computers aren't at all procedural, right?

  • (cs) in reply to ObiWayneKenobi
    ObiWayneKenobi:
    Matt Westwood:
    You don't know fucking shit, you prick.

    Hi Mort, is that you? How's your C#-written-like-VB6 coming along?

    No, it's not Mort, I killed him and ate him ages ago. Most of him, his bones were all rubbery though so I left those.

  • m (unregistered) in reply to dtech
    dtech:
    Static classes are perfect for methods that can be easily grouped, but aren't (logically) part of a class/object.
    Err, sorry, what about [a href="http://www.adaic.org/resources/add_content/standards/05aarm/html/AA-7.html"]packages[/a].
  • (cs) in reply to Nagesh
    Macho:
    Cool story, bro!

    I felt the need to pre-emptively defend my usage of Visual Basic .NET against the raving hordes of people who think anything with Visual Basic in the name (new or old) is the Worst Thing in the Entire Universe.

    Nagesh:
    If you are code in VB .NET why are you using CS program? Am I miss sumthing?

    The sample program for the library is in CS. My program is in VB. The library (obviously) works with both languages, but some of the samples were only provided in one.

  • Herby (unregistered)

    "A Trigger happy ex-girlfriend"...

    ..."Shall we shoot them?"

    If it were only that simple!!

  • Meep (unregistered)

    "In a strictly object oriented environment like C#/.NET," writes J.D., "there's really no such thing as 'global variables'. Sure, you can create global variables, but the folks looking to (ab)use global variables generally can't tell the difference."

    No, wait:

    "In a completely arbitrary object oriented environment like C#/.NET," writes J.D., "there's really no coherent notion of variables or values or types'. Sure, you can create classes and call methods and throw buzzwords around, but the folks looking to relate your steaming pile of illogic to anything remotely resembling math will have a hard time making that conceptual leap."

  • Meep (unregistered) in reply to Meep

    I seem to have experienced a case of complete and total markup failure.

  • Craig Tregear (unregistered)

    This sounds like the next evolution of some of the people that I went to University with.

    There was one person that was in my Introduction to Computer Science course who couldn't work out how to properly pass arguments (references/pointers) to functions. Instead, at the start of every function he would paste a snippet of code that he wrote to load all of his data from a file. Before he function call of course he would paste a similar snippet to save everything to a file.

    At least this is one step better than that....

  • (cs)

    Well there was quite a bit of editing on this story so don't assume that it's my grammar that's at fault. Not that I mind the editing at all, my submission was very light on (sorry!) and this gives a pretty accurate description.

    Fortunately the people responsible for this have left, which means I can rewrite the code without fear of retribution. Unfortunately it's all like this and I don't have time to rewrite it all. Don't even ask me about the static class with 2700 lines of public static methods and variables.

  • inline (unregistered) in reply to Nagesh
    1. Java developer no spell
  • Michaels (unregistered) in reply to Nagesh
    Nagesh:
    1. java developer never meke this mistake. 2. not all static method is bad. sometime static method is very useful. 3. peepul who lern vb6 and cum to OO background are total useless at geting their head around stuff. 4. drinking cofee stimulate brian cells. report availebel on http://www.bbc.co.uk/news/health-15059266 5. that is all for now.
    Meh...Who needs coffee? [image]
  • ersajkfmfh (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    hoodaticus:
    Procedural coders should be banned from .NET development.

    When Visual Studio starts up, it should require you to implement an OO design pattern in a mini-game. If you win, Visual Studio won't shock you with a cattle-prod and shove you down a large flight of stairs followed by several overloaded tape safes.

    FTFM
    I would qwite happily watch Visual Studio uninstall itself each time anyone tried to load it...

  • Some Dude (unregistered) in reply to Nagesh
    Nagesh:
    Solution! With help of collegue, I am geting farther on problum. Changing "bool" to Java type, I guet insted:<snip> helping plz?
    The new manifestations of Nagesh get worse and worse - not that the bar was so high to begin with, I suppose.

    Maroochydore!

  • haha (unregistered) in reply to The Great Lobachevsky
    The Great Lobachevsky:
    Yeah, there aren't any women in computers, right? At least any that know JavaScript. ;-)
    I've heard Jenny Simpson does....
  • Alexis (unregistered) in reply to ted
    ted:
    Nagesh:
    4. drinking cofee stimulate brian cells.
    I didn't even click on the link and knew it was some fag linking bbc. It's not clever. It's not funny. Just the word "cofee" with a link under it and the short, useless, one sentence point was all I needed to know that you were linking the article where the scientists iteratively one-up each other on how they stimulate brain cells.

    It was funny to read when it came out. It's even funny when clicking on the Random button on the site and seeing it. It's NOT funny when someone links to it from a one-sentence post and thinks they're so fucking clever to have discovered bbc.

    You probably still use lmgtfy and think you're so damn clever.

    It means in real life, you're an unoriginal hipster doofus.

    Got anything to do with sanitizing inputs to a SQL database, etc.? Link to Computer Security. Got a nerd-project slow-ass turing machine? Like a minecraft logic circuit from redstone? Link to the one where it's some guy alone in the Alaska making a firepit out of rocks. Got a story about Guantanamo? Link to the one where they beat the password out of the guy with a wrench.

    Fuck off. You're not clever.

    You missed any reference to Bobby Tables....

  • Sylvia (unregistered) in reply to dtech
    dtech:
    hoodaticus:
    ObiWayneKenobi:
    If it's not a class with nothing but static methods (used in moderation that's fine, all over the place not so much)
    I wouldn't permit static classes unless there is a damn good justification. Too many people in the hiring pool need to be deprived of their crutch if they are to learn anything.

    Yes, because

    Math m = new Math();
    m.setArgument1(5.0);
    m.setArgument2(7.0);
    m.doF();
    double result = m.getResult();
    

    Is so mucht better than

    double result = Math.f(5.0, 7.0);
    

    Static classes are perfect for methods that can be easily grouped, but aren't (logically) part of a class/object.

    Ofcourse in this example one could also argue that f() should be part of a class, but the function might be much broader than a specific class (e.g. fourier transformation just to give an example, but it might even be calculateTaxRate()).

    Perhaps the real WTF is OOP....

  • Guerilla (unregistered) in reply to Matt Westwood
    Matt Westwood:
    talentless_newbie (too lazy to log in properly):
    Even if the original coder came from a purely procedural background (and I admit, I did, too), surely it should have occurred to them to wrap all of those into a structure, one would think.

    If you have 45 'out' parameters in one method, if you don't at least wonder whether there is a better way pass around and manipulate stuff, you should give up and go back to being an enduser.

    I had precisely this sort of discussion with a programmer who insisted on his nine, ten, eleven etc. parameter methods and constructors. His argument: "But that would mean writing yet another class just to pass these parameters around between these one, two, three .... goodness, *six* classes. Yet *another* class!" Putting on a patronising voice: "Don't you think this will make it just a tiny little bit overcomplicated?"

    And don't try refactoring the code he wrote or he would complain to the manager you'd "changed his code".

    Had one conversation "Did you change my code?!?!?" he screamed across the office. "Yes I did," I replied, "It had shitty nappies." ("nappies": UK English for "diapers".)

    ]Once again, you impress me as some sort of Dickwad.

    There's obvioulsy noone in the universe who could produce code that's even close to your standard.

  • Stir the Pot (unregistered) in reply to Craig Tregear
    Craig Tregear:
    This sounds like the next evolution of some of the people that I went to University with.

    There was one person that was in my Introduction to Computer Science course who couldn't work out how to properly pass arguments (references/pointers) to functions. Instead, at the start of every function she would paste a snippet of code that she wrote to load all of her data from a file. Before the function call of course she would paste a similar snippet to save everything to a file.

    At least this is one step better than that....

    FTFY....it's alright, we know....

  • (cs) in reply to hoodaticus
    hoodaticus:
    Procedural coders should be banned from .NET development.

    When Visual Studio starts up, it should require you to implement an OO design pattern in a mini-game. If you win, Visual Studio won't uninstall itself, delete all your projects, and revoke your license.

    Some of the code in the codebase of my previous project was initially created by 'porting' FORTRAN code through use of Find and Replace. I've subsequently molded it into a more OO shape, and also been involved in training the author (not the porter) of the original code (who is also the product leader) in OO concepts.

    One of the strangest things I saw was chunks of FORTRAN code in a .cs file (retained to give context) not commented out, but rather prevented from compiling with #if.

    Alexis:
    ted:
    Nagesh:
    4. drinking cofee stimulate brian cells.
    I didn't even click on the link and knew it was some fag linking bbc. It's not clever. It's not funny. Just the word "cofee" with a link under it and the short, useless, one sentence point was all I needed to know that you were linking the article where the scientists iteratively one-up each other on how they stimulate brain cells.

    It was funny to read when it came out. It's even funny when clicking on the Random button on the site and seeing it. It's NOT funny when someone links to it from a one-sentence post and thinks they're so fucking clever to have discovered bbc.

    You probably still use lmgtfy and think you're so damn clever.

    It means in real life, you're an unoriginal hipster doofus.

    Got anything to do with sanitizing inputs to a SQL database, etc.? Link to Computer Security. Got a nerd-project slow-ass turing machine? Like a minecraft logic circuit from redstone? Link to the one where it's some guy alone in the Alaska making a firepit out of rocks. Got a story about Guantanamo? Link to the one where they beat the password out of the guy with a wrench.

    Fuck off. You're not clever.

    You missed any reference to Bobby Tables....
    relevant xkcd

  • Spider Flyer (unregistered) in reply to Michaels
    Michaels:
    Nagesh:
    1. java developer never meke this mistake. 2. not all static method is bad. sometime static method is very useful. 3. peepul who lern vb6 and cum to OO background are total useless at geting their head around stuff. 4. drinking cofee stimulate brian cells. report availebel on http://www.bbc.co.uk/news/health-15059266 5. that is all for now.
    Meh...Who needs coffee? [image]

    Actually, it was Jägermeister and a Slurpee machine. :-)

  • (cs) in reply to Herby
    Herby:
    "A Trigger happy ex-girlfriend"...

    ..."Shall we shoot them?"

    If it were only that simple!!

    "Eeny, meeny, miney, mo Catch a redneck by his toe ..."

  • (cs) in reply to Guerilla
    Guerilla:
    Matt Westwood:
    talentless_newbie (too lazy to log in properly):
    Even if the original coder came from a purely procedural background (and I admit, I did, too), surely it should have occurred to them to wrap all of those into a structure, one would think.

    If you have 45 'out' parameters in one method, if you don't at least wonder whether there is a better way pass around and manipulate stuff, you should give up and go back to being an enduser.

    I had precisely this sort of discussion with a programmer who insisted on his nine, ten, eleven etc. parameter methods and constructors. His argument: "But that would mean writing yet another class just to pass these parameters around between these one, two, three .... goodness, *six* classes. Yet *another* class!" Putting on a patronising voice: "Don't you think this will make it just a tiny little bit overcomplicated?"

    And don't try refactoring the code he wrote or he would complain to the manager you'd "changed his code".

    Had one conversation "Did you change my code?!?!?" he screamed across the office. "Yes I did," I replied, "It had shitty nappies." ("nappies": UK English for "diapers".)

    ]Once again, you impress me as some sort of Dickwad.

    There's obvioulsy noone in the universe who could produce code that's even close to your standard.

    First find some code of mine that you consider substandard, then feel free to challenge its quality, pissbrain. Then FOAD.

  • Random coder (unregistered) in reply to Matt H.
    Matt H.:
    TheSHEEEP:
    hoodaticus:
    Procedural coders should be banned from .NET development.

    They should be banned from pretty much anything. Just to be sure.

    Except crochet.

    Because computers aren't at all procedural, right?

    You should write such code that other coders can understand it. Compiler will translate the code to a language that computer understands.

  • (cs) in reply to Some damn Yank
    Some damn Yank:
    Bradley:
    (malformed quote was here)
    This board quotes everything for you. How did you manage to mess it up? Whatever you did even messed up my quoting of you!
    And yet neither of you managed to look at your posts for long enough to see the problem, which was really rather obvious (Bradley didn't delete all of the material he intended to, and deleted an opening quote but not the corresponding close quote). Do you get upset when your compiler complains because your opening and closing braces don't match up?
    foo:
    When you want to delete parts of a quote (to avoid pointless full-quotes) or insert text between quoted parts (like this one), you have to mess with the quoting tags.
    Well, deleting parts of a quote doesn't necessarily require it - only if the parts you're deleting cross the boundary of a nested quote. And then you're already messing with the quoting tags by deleting some, so all you have to remember is to keep them balanced correctly.

    And indeed you have the Preview button to check your posts before you send them off, so there's really not much excuse (and if you're registered, you can edit your post if you notice an error after the fact).

    Not that CS isn't a pile of WTF, but this is just laziness or carelessness on the part of the poster, not CS's fault.

  • (cs) in reply to Random coder
    Random coder:
    Matt H.:
    TheSHEEEP:
    hoodaticus:
    Procedural coders should be banned from .NET development.

    They should be banned from pretty much anything. Just to be sure.

    Except crochet.

    Because computers aren't at all procedural, right?

    You should write such code that other coders can understand it. Compiler will translate the code to a language that computer understands.

    Don't feed the troll, please!

  • gilgamash (unregistered)

    That's what happens if you can't or don't use macros and templates!

  • The Poop... of DOOM! (unregistered) in reply to hoodaticus
    hoodaticus:
    ObiWayneKenobi:
    Don't get me wrong. I think static methods have their uses, typically in what DDD people call the "Service" - components that *only* do input/output on something, but aren't directly related to any one entity or domain concept.

    That said even then I would prefer to use instance methods to use Dependency Injection/IoC, but having a static class that acts as a "broker" or possibly as a Factory pattern implementation is okay with me. I've used static methods in Factories that simply construct a domain object from some type of raw data.

    Having a single file with half a dozen classes inside that file, all of which have static methods, however, is blasphemy and anyone who does it should be fired immediately for being a clueless Mort; it shows not only no understanding of OOP but no understanding of component design.

    +5. It's not statics that are evil. It's the exclusive use of stateless classes to prove true the axiom "You can do FORTRAN in any language."
    Yup, did similar and I don't regret it. Code that has to access an external web service, pull in an XML file, cut it into little objects, transform it into another XML file and pass that on to another external web service. As there's no point in instantiating the connection, I made it a static class. Pass in the connection data once (as it simply isn't going to change during the procedure, and the other service used a completely different way of connecting, so couldn't reuse it), and then just call the functions. There's no point in instantiating something like that.

  • The Poop... of DOOM! (unregistered) in reply to Some damn Yank
    Some damn Yank:
    hoodaticus:
    It's not statics that are evil. It's the exclusive use of stateless classes to prove true the axiom "You can do FORTRAN in any language."
    Oh? Well, then, how would you prove true the axiom "You can do FORTRAN in any language." without stateless classes?
    Easy enough if all the FORTRAN you do, is Hello World. The only language that might be an exception, is perhaps ProLog, but I'm not sure. Only know the concept of it.
  • The Poop... of DOOM! (unregistered) in reply to PedanticCurmudgeon
    PedanticCurmudgeon:
    hoodaticus:
    PedanticCurmudgeon:
    Or better yet, Haskell gets installed if you lose. Let the punishment fit the crime. If you only write procedural code, you get a language where it's painful to write procedural code.
    Like!

    It would also be cool if it compiled all your projects to native assembly with NGEN, then deleted all the source.

    You want procedural? Here, have some MSASM.

    Or Forth, Befunge, Chef (for the sheer amount of typing needed to get anything done), or Piet for the technically challenged. There's all kinds of languages we can use to punish the clueless.
    FTFY

  • SpiderMonkey (unregistered)

    Of course globals exist in oo world, Can you say Singleton pattern!!

  • The Poop... of DOOM! (unregistered) in reply to Some Dude
    Some Dude:
    Nagesh:
    Solution! With help of collegue, I am geting farther on problum. Changing "bool" to Java type, I guet insted:<snip> helping plz?
    The new manifestations of Nagesh get worse and worse - not that the bar was so high to begin with, I suppose.

    Maroochydore!

    And that's why we need one static Nagesh class. That way, there won't be several instances... not even one, actually! Problem solved

  • Luiz Felipe (unregistered)

    Clearly exists a problem with mathematical operators being static and not instance methods.

    int x = 1; int y = 2; int i = x + y;

    If, by this logic, static is a bad thing that must be avoided like a plage. then the only correct way is:

    int x = 1; int y = 2; int i = x.add(y);

    But "int" is also a static type ( Static Languague, duh? ).

    object x = (new TypesFactory()).CreateIntFactory().CreateInt(IntFactory.Int1); object y = (new TypesFactory()).CreateIntFactory().CreateInt(IntFactory.Int2); object i = x.add(y);

    Much better now.

  • Luiz Felipe (unregistered) in reply to Luiz Felipe
    Luiz Felipe:
    Clearly exists a problem with mathematical operators being static and not instance methods.

    int x = 1; int y = 2; int i = x + y;

    If, by this logic, static is a bad thing that must be avoided like a plage. then the only correct way is:

    int x = 1; int y = 2; int i = x.add(y);

    But "int" is also a static type ( Static Languague, duh? ).

    object x = (new TypesFactory()).CreateIntFactory().CreateInt(IntFactory.Int1); object y = (new TypesFactory()).CreateIntFactory().CreateInt(IntFactory.Int2); object i = x.add(y);

    Much better now.

    I made a mistake, used static constantes int1 and int2, a little bit of refactorization.

    object tf = (new TypesFactory()).CreateIntFactory(); object x = tf.CreateInt(tf.Int1); object y = tf.CreateInt(tf.Int2); object i = x.add(y);

  • (cs) in reply to Luiz Felipe
    Luiz Felipe:
    Luiz Felipe:
    Clearly exists a problem with mathematical operators being static and not instance methods.

    int x = 1; int y = 2; int i = x + y;

    If, by this logic, static is a bad thing that must be avoided like a plage. then the only correct way is:

    int x = 1; int y = 2; int i = x.add(y);

    But "int" is also a static type ( Static Languague, duh? ).

    object x = (new TypesFactory()).CreateIntFactory().CreateInt(IntFactory.Int1); object y = (new TypesFactory()).CreateIntFactory().CreateInt(IntFactory.Int2); object i = x.add(y);

    Much better now.

    I made a mistake, used static constantes int1 and int2, a little bit of refactorization.

    object tf = (new TypesFactory()).CreateIntFactory(); object x = tf.CreateInt(tf.Int1); object y = tf.CreateInt(tf.Int2); object i = x.add(y);

    That's a bit shit. You can't have Int1 and Int2 and expect us to believe this is sensible. What about:

    object tf = (new TypesFactory()).CreateIntFactory(); object x = tf.CreateInt(1); object y = tf.CreateInt(2); object i = x.add(y);

    Now, as it stands, that's almost sane.

    In java, that would be:

    IntegerFactory f = IntegerFactory.getInstance(); Integer x = f.CreateInt(1); Integer y = f.CreateInt(2); Integer i = x.add(y);

    You could go a step further and go:

    Integer x = Integer.getInstance(1); Integer y = Integer.getInstance(2); Integer i = x.add(y);

    Can't be bothered to look up the precise syntax for the above (it's probably not getInstance, but I'm not in front of an IDE at the moment and I can't be arsed to look it up), so the detail is probably wrong.

    Fortunately java has plenty of syntactic sugar so the above is not necessary.

    Anyone who suggests that static methods are wrong is full of shit.

  • (cs) in reply to Matt Westwood
    Matt Westwood:
    Anyone who suggests that static methods are wrong is full of shit.

    But nobody said "static methods are wrong". What was said is "Static methods should be use sparingly". I said myself that I've used static methods, but I wouldn't make EVERYTHING static methods, and I wouldn't trust any developer clueless enough to think that it's okay to have classes that should be instances have nothing but static methods because they can't be arsed to instantiate something.

  • Nagesh (unregistered) in reply to ObiWayneKenobi
    ObiWayneKenobi:
    Matt Westwood:
    Anyone who suggests that static methods are wrong is full of shit.

    But nobody said "static methods are wrong". What was said is "Static methods should be use sparingly". I said myself that I've used static methods, but I wouldn't make EVERYTHING static methods, and I wouldn't trust any developer clueless enough to think that it's okay to have classes that should be instances have nothing but static methods because they can't be arsed to instantiate something.

    Being said in an earlier post: static method (in Java only, not knowing about C♯) not allowed to be using for IoC design paterns. Making your clases SINGLETON in Spring and can be having globle method for use: spring.xml

    <bean name="foo"
          class="com.india.nagesh.Brillant" singleton="true"/>
    </bean>

    Putting method on Brillant class, using by:

    ApplicationContext ctx = 
                 new ClassPathXmlApplicationContext("matterhorn.xml");
    ((Brillant) ctx).getBean("foo").notStaticMethdo();
  • Nagesh (unregistered) in reply to The Poop... of DOOM!
    The Poop... of DOOM!:
    Some Dude:
    Nagesh:
    Solution! With help of collegue, I am geting farther on problum. Changing "bool" to Java type, I guet insted:<snip> helping plz?
    The new manifestations of Nagesh get worse and worse - not that the bar was so high to begin with, I suppose.

    Maroochydore!

    And that's why we need one static Nagesh class. That way, there won't be several instances... not even one, actually! Problem solved

    We are already having a static Nagesh class, and it is being able to be called from any TDWTF poster. This is the problem, you see. I am thinking that a singleton is perhaps a better solution to the problem that we are having.

  • (cs) in reply to hoodaticus
    hoodaticus:
    I wouldn't permit static classes unless there is a damn good justification.
    java.util.Arrays and java.util.Collections :)

    Although especially the former is perhaps not the best example...

  • (cs) in reply to Nagesh
    Nagesh :
    We are already having a static Nagesh class, and it is being able to be called from any TDWTF poster. This is the problem, you see. I am thinking that a singleton is perhaps a better solution to the problem that we are having.
    I have a solution that will satisfy everyone that matters: make the Nagesh class private.
  • Nagesh (unregistered) in reply to hoodaticus
    hoodaticus:
    Nagesh :
    We are already having a static Nagesh class, and it is being able to be called from any TDWTF poster. This is the problem, you see. I am thinking that a singleton is perhaps a better solution to the problem that we are having.
    I have a solution that will satisfy everyone that matters: make the Nagesh class private.
    Colege student who stolen my acount not having been posting yet. Thinking he is in U.S. defacing my good name, but not having been woke up after long drinking party.
  • (cs) in reply to Nagesh
    Nagesh:
    ObiWayneKenobi:
    Matt Westwood:
    Anyone who suggests that static methods are wrong is full of shit.

    But nobody said "static methods are wrong". What was said is "Static methods should be use sparingly". I said myself that I've used static methods, but I wouldn't make EVERYTHING static methods, and I wouldn't trust any developer clueless enough to think that it's okay to have classes that should be instances have nothing but static methods because they can't be arsed to instantiate something.

    Being said in an earlier post: static method (in Java only, not knowing about C♯) not allowed to be using for IoC design paterns. Making your clases SINGLETON in Spring and can be having globle method for use: spring.xml

    <bean name="foo"
          class="com.india.nagesh.Brillant" singleton="true"/>
    </bean>

    Putting method on Brillant class, using by:

    ApplicationContext ctx = 
                 new ClassPathXmlApplicationContext("matterhorn.xml");
    ((Brillant) ctx).getBean("foo").notStaticMethdo();

    Java EE and most associated frameworks are why we can't have nice things. Also, since Java doesn't have the concept of AppDomain, singletons are shared across the whole JVM,which seems pretty WTFy to me.

  • (cs) in reply to hoodaticus
    hoodaticus:
    Nagesh :
    We are already having a static Nagesh class, and it is being able to be called from any TDWTF poster. This is the problem, you see. I am thinking that a singleton is perhaps a better solution to the problem that we are having.
    I have a solution that will satisfy everyone that matters: make the Nagesh class private.
    I for one, welcome our new Nagesh overlords.
  • (cs) in reply to The Poop... of DOOM!
    The Poop... of DOOM!:
    hoodaticus:
    ObiWayneKenobi:
    Don't get me wrong. I think static methods have their uses, typically in what DDD people call the "Service" - components that *only* do input/output on something, but aren't directly related to any one entity or domain concept.

    That said even then I would prefer to use instance methods to use Dependency Injection/IoC, but having a static class that acts as a "broker" or possibly as a Factory pattern implementation is okay with me. I've used static methods in Factories that simply construct a domain object from some type of raw data.

    Having a single file with half a dozen classes inside that file, all of which have static methods, however, is blasphemy and anyone who does it should be fired immediately for being a clueless Mort; it shows not only no understanding of OOP but no understanding of component design.

    +5. It's not statics that are evil. It's the exclusive use of stateless classes to prove true the axiom "You can do FORTRAN in any language."
    Yup, did similar and I don't regret it. Code that has to access an external web service, pull in an XML file, cut it into little objects, transform it into another XML file and pass that on to another external web service. As there's no point in instantiating the connection, I made it a static class. Pass in the connection data once (as it simply isn't going to change during the procedure, and the other service used a completely different way of connecting, so couldn't reuse it), and then just call the functions. There's no point in instantiating something like that.
    First of all, it sounds like you're doing XML transformations wrong.

    Second of all, you aren't likely to figure out the benefits of using OOP here until you actually do it.

    My ActiveDirectory class didn't start out all advanced with every bell and whistle. But because I didn't make it a static class, I was able to grow it over time into the feature-packed, performant beauty of OO design that it is today.

    To get the same functionality I ended up eventually needing in my ActiveDirectory class using a static class would have required dozens or hundreds of static methods. It's a lot less ugly when those methods are bound to data rather than using spaghetti code/static classes.

    OOP is a good thing. I have never once written a stateless class (other than extension methods).

    On to your example. XML receipt, processing, and transmitting is one of the most common things you have to do today. I went the other direction than you and made my own Xml namespace with classes like Post<T>, ElementDispatcher<T>, and ElementAction<T> (although that last one is a struct) to encapsulate the whole process.

    Now all my streaming XML parsing is generic + generalized, and I will never, ever write that code again. But you will. All I have to do is specify endpoints, elements, and the lambdas that act on the elements in the XML stream and the target T that will be modified by those lambda statements.

    OOP is better than what we had before. You will get much further with it than you will by regressing back to the most primitive programming techniques.

    Addendum (2011-09-29 09:30): And by "never once written a stateless class", I am not referring to SOA. SOA might get away with statelessness, although all of my RESTful work still caches behind the scenes...

  • Nagesh (unregistered) in reply to frits
    frits:
    Nagesh:
    ObiWayneKenobi:
    Matt Westwood:
    Anyone who suggests that static methods are wrong is full of shit.

    But nobody said "static methods are wrong". What was said is "Static methods should be use sparingly". I said myself that I've used static methods, but I wouldn't make EVERYTHING static methods, and I wouldn't trust any developer clueless enough to think that it's okay to have classes that should be instances have nothing but static methods because they can't be arsed to instantiate something.

    Being said in an earlier post: static method (in Java only, not knowing about C♯) not allowed to be using for IoC design paterns. Making your clases SINGLETON in Spring and can be having globle method for use: spring.xml

    <bean name="foo"
          class="com.india.nagesh.Brillant" singleton="true"/>
    </bean>

    Putting method on Brillant class, using by:

    ApplicationContext ctx = 
                 new ClassPathXmlApplicationContext("matterhorn.xml");
    ((Brillant) ctx).getBean("foo").notStaticMethdo();

    Java EE and most associated frameworks are why we can't have nice things. Also, since Java doesn't have the concept of AppDomain, singletons are shared across the whole JVM,which seems pretty WTFy to me.

    Class sharing being introduced in JDK1.5, but my shop command to use 1.2 (more stabel) for most things.
  • (cs) in reply to hoodaticus

    i am allmost positive fake nagesh is opereted by frits or boog.

  • Nagesh (unregistered) in reply to Nagesh
    Nagesh:
    i am allmost positive fake nagesh is opereted by frits or boog.
    Booger not being seen around here in long time...just like you have been on sumer holiday after haking my acount.
  • (cs) in reply to Nagesh
    Nagesh:
    i am allmost positive fake nagesh is opereted by frits or boog.
    Based on what evidence? I like your posts, and fake Nageshes' as well, even if you don't like mine. Also, boog hasn't posted any comments in a month or more AFAIK. I think someone hurt his boo boo, or he is just over it, or has more important things to do.

    BTW- Who is frits, but a registered sock puppet anyway?

Leave a comment on “The Global Workaround”

Log In or post as a guest

Replying to comment #:

« Return to Article