Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Telastyn

Member Since 13 Oct 2003
Offline Last Active Mar 13 2015 01:23 PM

#5207489 Some programmers actually hate OOP languages? WHAT?!

Posted by Telastyn on 29 January 2015 - 01:00 PM


Something I still haven't got is the difference between OOP and simply using objects.

 

It's blurry, since different people consider OOP different things. Generally though, Object Oriented Programming isn't programming, it is design.

 

When you go to break your problem into managable chunks, do you think "what parts make this up?" (OO), "what steps do I need to take?" (procedural), or "what operations make this up?" (functional).




#5207463 Some programmers actually hate OOP languages? WHAT?!

Posted by Telastyn on 29 January 2015 - 11:14 AM

One other thing that should be mentioned is that OOP has changed quite a bit over its existence. Inheritance for example is generally seen as something to avoid these days. Mutable state in objects is generally seen as something to avoid these days.

 

Why? Because programmers used them and found out that in many cases they suck. Some programmers said "let's make this better". Some programmers said "screw it, I'm going back to my cave" and haven't seen the practical improvements made in OOP technique over the decades. If all people know of OO is old style inheritance heavy, side-effect heavy code - they are completely right that it is bad.

 

Likewise, many of the other commenters are correct that C++ is a pretty terrible language to make OO code in. Java is a pretty terrible language to make pragmatic OO code in. Universities were horrible at teaching OO throughout the 90's and early 00's (and are still largely terrible). If all you see is horrible OO code, it's not a terribly improper leap to assume that it is terrible, or it makes it too hard to write not-terrible code.

 

Another thing to consider is personal experience. Like others have mentioned, OO is a tool and like any tool is good at some things and bad at others. If my experiences tell me that most problems are these sort (that OO happens to solve well) or that these sorts of things cause me pain (which OO prevents) then I'm going to think OO is awesome. Some people's experience simply tells them that the verbosity of most OO languages provides no benefit, or the object focused approach yields inferior solutions for the sort of problems they commonly encounter.




#5121060 Modifying my own code while it's running

Posted by Telastyn on 03 January 2014 - 09:24 PM

Enh, up I imagine the runtime modification would screw up your profiling more than simply including it always (in beta) and turning on logging when needed. When done judiciously, it won't substantially impact performance but still give you plenty of instrumentation to identify issues.


#5121056 Modifying my own code while it's running

Posted by Telastyn on 03 January 2014 - 09:07 PM

You're better off using an aspect oriented programming framework like PostSharp to inject these things during a build step rather than at runtime. I'm not sure how viable ubiquitous runtime modification of a loaded assembly is.


#5119197 Having trouble accessing an objects properties.

Posted by Telastyn on 25 December 2013 - 09:06 AM

The solution is to not need BladeWarrior's methods to fight. Generally that means making common methods available on character, making BladeWarrior an instance of Character (rather than a derivative of it), or by letting the thing that controls the fighting get a BladeWarrior rather than a Character array (though that one depends a lot more on how your game works).


#5113375 Code Review - Event Use?

Posted by Telastyn on 30 November 2013 - 05:59 PM


I know it would work fine, but in the interest of the single responsibility principle, would it be ok?

 

But it has a single responsibility: to allocate power to a subsystem. It knows how to tie the various other single responsibilities together. Something has to do that after all.

 

It might be good to separate that responsibility from the power source, but I'm not sure the decoupling benefits (flexibility, testability) here are worth the downsides (more overhead, harder to implement/read/maintain).




#5113262 Code Review - Event Use?

Posted by Telastyn on 30 November 2013 - 08:35 AM


The only other way I see writing this is if I pass instances of the relay, warp core, and subsystem to each other.

 

Yes, that seems to be the obvious thing to do.

 


Feels over kill

 

Just passing things around is the simplest, most straightforward way to code. It should be your default approach until you have some requirement (there may or may not be something passed in, there may be N things passed in at any given time, there may be things in weird plugins we don't know about).

 

I don't know your requirements but I would approach it like this:

public interface Subsystem {
        bool IsPowered { get; }
        int MaxPower { get; }
        int PowerLevel { get; }
    }

    public interface PowerSource {
        int SuppliedPower { get; }
        IEnumerable<KeyValuePair<Subsystem, int>> PowerAllocation { get; }
        void AllocatePowerToSubsystem(Subsystem target);
    }

If you can't simply allocate any subsystem to any power source, the Allocate method may need to be in a higher level "Ship" object. Either way, the entire logic for that operation lives in the one method devoted to doing it - not spread across 6 event handlers which provide no benefit.




#5101153 Am I read to start making games yet?

Posted by Telastyn on 13 October 2013 - 07:36 PM

I will disagree with some of my colleges here...

The old "If you have to ask..." line of idioms comes to mind here. It is (or should be) pretty obvious as you're learning to program how you can apply this thing you learned into making a (ugly, incomplete, stupid, buggy) game. Just take X and make that HP, and take Y and make that some enemy and *poof* you have a game rather than a homework problem.

...if you can't see that, or somehow can't envision how a game would work - then you're not ready. You'll just flounder, or worse, copy-paste some code and have no idea how it works or how to adapt it to your problem. Just keep moving forward. It doesn't really matter where you are (or even where you're going) as long as you keep improving.


#5100048 How to get motivated to learn Programming?

Posted by Telastyn on 09 October 2013 - 08:21 PM

I don't mean to more of a sourpuss than normal, but you don't need a mentor to learn to program, you need to learn how to learn; and learn how to work effectively. Eventually the mentor will leave or the engaging web tutorial will end. What then? You get to the part that is actually hard: slogging through years of unfun debugging and polish to make (statistically) a really bad, ugly game work.

All the programming-fu in the world will not help you if you cannot develop the work ethic (or at least stubbornness) to put it to use.

Hopefully this advice will help, even if I have no idea how to achieve it. For me, it took a whole lot of trial, error and introspection while failing my way out of college.


#5093168 CS Degree - Is it worth it?

Posted by Telastyn on 10 September 2013 - 07:21 PM

Pssh. It's as good a reason as any. You're only 18-22 once, and if you're off being an adult you'll generally have a very hard time finding friends (and dating partners) around your age - they're all off at college.

Learning who you are is a key part of college, and sexuality is an important aspect of adulthood. Beyond that, the social aspects of finding and maintaining relationships are important skills to grow so that you can be successful both professionally and personally.

It's certainly not a key reason you should go to college, but seeing "I already know how to program" as the only aspect of improvement at school is absurdly shortsighted.


#5092499 Stick with C++ or venture into C#?

Posted by Telastyn on 08 September 2013 - 10:51 AM

I personally have a lot less aggravation using C# than C++. Games are hard (and frustrating) enough that adding to that is unwise.




#5092491 CS Degree - Is it worth it?

Posted by Telastyn on 08 September 2013 - 09:45 AM

As a skilled programmer without a degree (yet), let me say in no uncertain terms: get a degree.
Even if you can _do_ the job, getting that first job is tons easier with a degree. HR departments (and most hiring managers) will hire a candidate with a degree over one without. And even when you do get a job, you'll get paid far less than a "more qualified" candidate.
And really, why would you *choose* to slave away 40 hours a week rather than spending 4 years hanging out with uninhibited coeds?

 
Uninhibited coeds tend to have an inverse financial effect when compared to employment.

I have lost somewhere around $25-30k *per year* over the past 15 years by making less than my degree'd peers. And that doesn't include the 15 months I spent unemployed because nobody would hire a non-degree'd computer programmer with no formal experience.

Not getting a degree is absurdly more expensive than even today's universities.


#5092383 CS Degree - Is it worth it?

Posted by Telastyn on 07 September 2013 - 08:13 PM

As a skilled programmer without a degree (yet), let me say in no uncertain terms: get a degree.

Even if you can _do_ the job, getting that first job is tons easier with a degree. HR departments (and most hiring managers) will hire a candidate with a degree over one without. And even when you do get a job, you'll get paid far less than a "more qualified" candidate.

And really, why would you *choose* to slave away 40 hours a week rather than spending 4 years hanging out with uninhibited coeds?


#5086761 Reference to a Reference?

Posted by Telastyn on 17 August 2013 - 07:38 AM

Is this possible without venturing into unmanned code land?

 

 

In general, the C# idiom is to make RefToRefCow a Func<RefCow>

var RefCow = Cow1;
var RefToRefCow = ()=>RefCow;
RefToRefCow().HowMuchWeight();  // 5

RefCow = Cow2;
RefToRefCow().HowMuchWeight(); // 10



#5078671 Programming the right way?

Posted by Telastyn on 18 July 2013 - 04:59 AM


Can anyone point me in the right direction to coding the right way with less bugs and more reliability?

 

First things first, there's no "right" way - there are a bunch of ways that will get the job done well.

 

Beyond that, I would look at the code you have written, and figure out why there are bugs. Did you use certain patterns that made the code fragile? Did you name things poorly so they got misused? Did the functions have too many side effects? Did you not have a good process to prevent typos/merge errors/etc?

 

Books and even good programmers can only bring you so far. Eventually you have to internalize the knowledge so that you can get the feel of what things are troublesome and why; what things are usually good and why. Then you can better apply those things to the problems at hand.






PARTNERS