I Have Found Python and… Well I’m Bored.

A while back I wrote a little ditty on python (Not sure if that’s the correct usage of ditty but when have I ever showed a need to use words correctly?) and at the time I was wowed by how easy it was to develop with Python and (“Wish I were getting money for this plug” plug) Pycharm. Sites were so much easier to create using the Pyramids engine. Everything was wonderful.

Enter Andre and the good ship .Net. Andre has an idea of creating a site for cancer survivors (Completely non shameful plug) and at first I was a little reluctant to go back to .Net. And honestly, if it weren’t for how complicated it is to set up python on a server, I probably wouldn’t have. But being as it is, I decided to take another run at .Net 4.0 and MVC 3.0.

Until that time, there had been something nagging me about Python. It wasn’t the performance since it seemed to work very well. It wasn’t the language syntax. I really like the forced syntax since it helps to keep standards. And I like dynamic languages like a person who likes dynamic languages. The f–k was it?!… Sorry that sentence was uncalled for. I’ll try again What the f–k was it?! I mean the language was built to be easy to use and easy to build with. And honestly, it is. What wasn’t I happy with it? WHY CAN’T I JUST BE HAPPY!?!?!?1117

Well right before I went back to C# for the site, I was sort of dreading the idea of having to work in a semi non dynamic and ridgid language. But it was for a good cause and like a man trapped in a jell-o wall, I would just have to push my way through. (Ok so I’m not exactly Leslie Nielsen here)

Then something magical happened. Maybe not David Bowie Labyrinth like magical, but still some degree of magicness. What was this crazy thing? I actually remembered why I liked programming in the first place. Yes C# isn’t as easy to use as Python. Yes it’s more rigid and demanding. Yes you end up with a ton more classes and flies for that matter. BUT I think that because Python is so easy to use, it stifles imagination and creativity. Everything is so lax and unpunishing in Python that it’s so easy to forget the more intellectually (And I use that word loosely in reference to me) challenging aspects of programming. You don’t need interfaces. Mocking object for unit tests is stupid easy. Hell you can even get away with out really creating many classes. Everything is so d—ned easy.

Yeah I know, I’m nuts. I don’t think there’s any question about that. With that said, I think there is some truth in what I’m saying. If you are just a paycheck programmer, you probably could happily roll with Python as it’s structure is by far easier to work with. If you really enjoy the challenge of creating systems that can be refactored and decouple constantly, it’s kind of boring. Don’t get me wrong, you can still do these to some extent with Python but in reality there’s only so many ways you can improve what you have. Far as I know, that’s by design since Python was created more for fast prototyping and development.

I guess I would compare it to cars. Some people would rather spent more money to get the complete package. You could go and buy the new 2012 Mustang Boss and get it loaded for about 45k OR you can buy a GT and spend less than the 15k price gap on aftermarket parts. They both would end up with great performance and both could have good arguments on which is the better way to go. It just depends on the kind of person you are. Some people like the easy path because it’s most likely the faster path. The others, well the others like the journey to get where they want to get. The old “Life’s a journey, not a destination.” cliche.

Which is better? Well that’s up to you. On one hand have Python that is built for fast production. The other is C# that can provide more self challenge and to some more self enjoyment from the challenge. Not sure which side is right, but I just seem to lean to the latter.

Does that make me a horrible person? No it’s just what I like. However, the drink I thought up that’s made from freshly squeezed celebrities might. (Now with less pulp)

Things You Need to Know about Jobs in IT: Free EBook

Somewhere about a year and a half ago or so, I thought to myself, “Self, what do you do well?” Besides the ability to watch Star Trek the Motion Picture twice a week in any given week, I came up with my ability to get a job no matter where or what (including an imploding stock market). I would like to say it’s because of my uncontainable amount of awesome, but it’s mostly that I’ve had 10 jobs in as many years. I know that sounds bad, but with that comes a lot of interviews. And a lot of conversations with recruiters. And a lot of experience with contracts, salary issues, company double talk, and well, a lot more. Basically every step of the hiring process and leaving process.

Then I realized there’s even more than that…

As conceited as this might sound, I started to see that I actually have a lot of knowledge on the given subject. Seemed like kind of a waste to keep it in my head and more accurately, in my brain. (As we all know from the world renown anatomy professor Pudge Rodriguez, “because in the head is the brain.”)

So I started writing everything I could think of down. Anything from how recruiters work to how to avoid costly (Money yo) mistakes when it comes to contracts. Today, I have it ready for the world (or the two people that come here) to see.

Basically it’s the book I wish I had years ago. Then again, if I had it years ago, I wouldn’t have written it. And if I hadn’t written it, I wouldn’t have had it years ago. And if I didn’t have it years ago, I would have written it now…

If you’re an experienced worker you might be thinking, “I don’t like taffy…”, but you might also be thinking, “I can get a job just fine, what the hell could this do for me?”

And that would be a good question. The answer is: It’s not just about getting a job. It’s getting a job YOU want and making sure you get it by beating everyone else out. I won’t lie, experience helps to get most jobs. But I’m not talking about most jobs, I’m talk about the jobs you want. There are a lot of people out there with experience, and there are only so many good jobs. You’ll need every little bit to be triumphant.

So with that in mind…

ByATool.com Presents:

Getting a Job in IT

This eBook will teach you about…

[box type=”tick” style=”rounded” border=”full”]Common Resume Mistakes[/box]
[box type=”tick” style=”rounded” border=”full” width=”300″]How To USE Recruiters[/box]
[box type=”tick” style=”rounded” border=”full”]All the types of Interviews and how to ACE them[/box]
[box type=”tick” style=”rounded” border=”full”]Detailed analysis of contracts[/box]
[box type=”tick” style=”rounded” border=”full”]Detailed analysis of salary[/box]
[box type=”tick” style=”rounded” border=”full”]What to look out for when it comes to salary[/box]

Inside, you will find advice like this…

[quote style=”boxed”]
Be very careful what you say your job title was.If someone calls on a reference and says something like “How was Johnny as an architect?” and you were really a junior developer, bad things happen; Very bad things.

[/quote]

and…

[quote style=”boxed”]
Something you may not understand about the HR side of interviewing is that you aren’t looked at to hire, you’re looked at to eliminate.If you are in a very competitive environment with lots of candidates, the best way to deal with this is to get rid of as many as possible right off the bat.

[/quote]

Has the Programmer Dream Died?

I realize that developers don’t have a Hippocratic Oath but I figure if it did exist would follow in the same footsteps.

I swear to complete my task to the best of my ability.
I will not settle for good enough to complete a task.
I will admit when I don't know and seek help from those who are more knowledgeable.
I will never obfuscate to ensure my continued employment.
I will prevent future issues by taking care of current ones.

And so on. Now this may not fit with all developers, but I have to think there’s a decent amount of developers that would like to hold this oath as a guideline for development.

“Aye, and if my grandmother had wheels, she’d be a wagon.”

I would have to think that such an oath would work if lives were at stake like they are in medicine. After all, there’s a pretty good indication of failure when a person lives or dies. Programs for the most part are a bit more gray. How many times have you walked into a new job to work on a system that is less than optimal? Then how many times have you asked how the client can stand it and the answer is, “They’re used to it.”

As horrific of a statement that seems to a developer, to the business it’s really not that big of a deal as long as the customer keeps paying. Rewrites and major updates just aren’t going to happen due to the old adage, “If it ain’t broke, don’t try to fix it.” After all, taking time to fix may delay any new features and then could open up a window of opportunity for the competitor. Beyond that, it’s probably a tough sell to the customer. “Sorry we need you to pay more for what you have now because the people we had before working on it weren’t very good. But we seriously have good people this time around! Looooooove youuu.”

So most programs are set in this sort of “Fix it however you can now and we’ll address later” which is the development equivalent of “Don’t call me, I’ll call you.” Of course fixing however it can be fixed only leads to more issues down the road. Around and around the wheels go on the bus.

Because of this unfortunate paradox, I think a little of us dies each time we work on a system. We start to break our oath a bit more every day until the point where we either jump one sinking ship for another or just phone in the code and learn to say, “It’s just work.”

Kind of the overdone cliche about a state representative that sets out to change the world only to end up being accused of snorting cocaine with hookers in Vegas.

I think a good amount of people, and maybe I’m insane (Which I am), want to do it the right way. They want to constantly improve that they’re working with. Problem is, this just doesn’t fit the business mind in the US. (Or other countries, but I can’t speak to that) The US Business culture just isn’t about doing it right, just doing it fast. So systems get built fast, are poorly tested, and covered with layer and layer of “fixes” to the point where it’s so massive that no company will pay to rewrite it. And even if they do, chances are the same attitude that build the mess in the first place will just show up again. Two months after pulling the company off a ledge, you’re ready to get up on that edge.

So how can we solve this? Can it be solved at all? Do any companies get this right and if it does, are they few and far between? Do you have to be in the 90 percentile to get that job?

I have to admit that from time to time I’ve wondered about this. I mean sure you hear of the mystical land of Google or Microsoft, or places built on magical things like TDD and Agile development. But hell, there are only so many jobs and only the top people get them. Does this mean the dream is dead for the unchosen many? Is it possible to bake your oath and eat it too?

MVC3, Entity Framework, jQuery… Everything example

How would you like to have a project that has these features?

Dependency Injection
Entity Framework 4.0 with POCO
Inversion of Control with Castle
The IResult
jQuery
jQuery Ajax Posts
jQuery Custom Css
jQuery Validation
Mocking with Rhino Mocks
MVC 3/Razor
MVC Annotation Based Validation
What I call the Repository Pattern
Unit Tests - Integration With Entity Framework
Unit Test - MVC Controller Actions

And more s--t I can't think of right now!

What’s the price of this gem? Just your time which is worth nothing!

Where can you find it? Right here!

Requirements:

Visual Studios 4.0
Mvc 3
To open the solution and do a search and replace on "Tutorial" to set your directory paths.
A real f--king need to learn!

Act now, operators aren’t in existence since this is hosted on a website, but if they were they would be standing by!

Disclaimer:

This may or may not hit you with a wave of awesome. Be prepared for the worse case awesome scenario. I am in now way responsible for any heart stoppage due to the shock and awe power of the project.

What Defines a Bad Developer?

This is more of a question post than one with answers ’cause I’m all mysterious like that.

Today I was debating (and by debating I mean fat fingering my way through instance messages) with a co worker about whether a certain somewhat well known developer was good. Though I won’t divulge such a person, let’s just say he’s built a a game that might or might not have to do with mining and/or crafting.

I can’t remember how we got on the subject, but his contention was that such a developer was horrible. This made me pull out the big guns loaded with pure dickish and fired off this salvo:

Well when you write a program that surpasses 100000+ users, I suppose that can be your rock to throw

Nothing inflammatory about that, right?

So from there it became an amazingly deep debate that could match the irrelevance of the most heated of Star Wars versus Star Trek debates.

Ok maybe it did have some usefulness to it. After all, it is a good question to ask… which is why I am asking it.

My point was that it’s not easy to make a game, even one that couldn’t give Quake a run for its money in the graphics area. (And yes I mean Quake 1… You know, that game that had polygons that would suggest you were holding a weapon but you were never quite sure.) And to make something like that in his spare time proves that’s he’s at least competent.

His main point was that as a part of professional pride, the game shouldn’t be as buggy as it is. The inability to create a product that didn’t have a solid foundation is just bad. Flat out bad. After all if I build a car, that’s cool. However, if I’m trying to run over some jack–s with three collars popped and due to lack of control takes out an Apple Store…. ok bad example. Takes out Mel Gibs… –CK! Takes out a puppy store, that doesn’t really mean I’m a mechanical genius regardless of other factors involved building it.

And I think in there is the question. Should things like time constraints, degree of difficulty, and having no help (That I know of until end of last year) be taken into account when you look at a body of work, or should it be the end product and end product only that defines the competence of the coder?

I think it can go either way depending on what you consider ability. Is ability defined as doing something difficult AND doing it well or just being able to churn out something a good majority of developers couldn’t do alone.

Now make no mistake, I’m not saying he’s the best developer ever. I’m sure there are people far beyond his ability. I just don’t buy that he’s incompetent due to the more intangible things that effect development.

Off Topic: Finally Hit 500 on Deadlift

Yeah I know, kind of lame to announce this on a programming blog, but this is a huge thing for me. I’ve come close to 500 quite a few times but there was always something that set me back. It isn’t the best lift ever, but still happy with it overall as I didn’t cheat the pull in any way. And as making claims without proof on the internet is pretty common, I figured I’d post the video.

Looking to set a new personal record on the bench at 330 this week. 325 is something that I’ve done on a few occasions, but like I said, something always came up.

WARNING: Sound is probably bad unless you want to hear a nerd war cry at the end… That and apparently I swore at the end too.

Pycharm: Change Error Alert Color/Style

Once again I’m using my blog to help remind myself of something later, but you know what? I’m OK with that.

Took a little bit to find this one, but changing the color of Errors and Warnings makes it hell of lot easier to find them. Go figure that the default “barely more grey than white” color doesn’t do the same.

Anyways:

File -> Settings -> IDE Settings -> Colors & Fonts -gt; General

At that point you’ll see stuff to the left with a bunch of colors. (Default Text) Just click on either Error or Warning to change them. After you’ve done that, feel free to go back to your project and find all the errors you couldn’t see before. It’s OK that you have errors though. Awesome as I am, even I make mistakes. Haha just kidding. Be ashamed of yourself.

Mock SQLAlchemy scoped_session query and Why Python is My BFF

sqlAlchemy has sessionmaker to create a session from which you can use query to get whatever you need. For example:

someSession.query(SomeTableRepresentationObject).filter...ect

If you’ve used sqlalchemy, nothing new going on here but it wouldn’t be me if I didn’t point out the obvious and take three sentences to do so.

Now what you may run into is something like this:

def getCountOfUsersByUserName(userName, session):
  return session.query(User).filter(User.userName == userName).count()

Ok now that I typed that out, I see it’s kind of a dumb method. But f–k it, what’s done is done.

Now from a testing situation, this could look tough. After all if you come from a more static language background like I did, you should know how hard things can be to mock at times. (.Net Session… I’m looking at you with judging eyes. Sooooo judging.) But this isn’t a static language, it’s Python.

For purposes of making things less confusing, which is hard for me, when I use the word “Object” I mean method OR class. And remember as always, “banana” is the safe word.

You see, to mock that out all you need is an object that has a query object that takes in something and a filter object on the query object that takes in something and has a count method on it. Yeah that totally makes sense. Try working it backward.

Filter has one parameter and a count method on it. Whatever that parameter is, it doesn’t matter since it is Python. As long as Filter takes in one parameter, you have a winner.

Query, like Filter, takes in one parameter and has a object named Filter on it. Once again, it doesn’t matter what’s passed into Query, just that it takes something in.

Session is basically an object that has no parameters and has a Query object on it.

Now in a static language, this would be annoying. You would need 3 interfaces and mock a whole ton of stuff dynamically with something like Rhino Mocks or just create a bunch of classes of those interfaces that you can pass in. Either way, there are complications. Once you get into things like Web Session or ViewState, it’s a ton of work. Python? Eh, you can do it in 20ish lines. How you ask? Well I’ll show you how!

	class mockFilter(object): #This is the ONE parameter constructor
		def __init__(self):
			self._count = 0
			self._first = dynamicObject()

		def first(self):  #This is the another method that's just coming along for the ride.
			return self._first

		def count(self):  #This is the needed Count method
			return self._count

	class mockQuery(object): #This is the ONE parameter constructor
		def __init__(self):
			self._filter = mockFilter()

		def filter(self, placeHolder): #This is used to mimic the query.filter() call
			return self._filter 

	class mockSession(object):
		def __init__(self):
			self._query = mockQuery()
			self.dirty = []

		def flush(self):
			pass

		def query(self, placeHolder):  #This is used to mimic the session.query call
			return self._query

  #and this... THIS IS SPARTA!!1111... yeah I know, I'm about 3 years too late on that joke.

How does this work? Say I have the method from above:

def getCountOfUsersByUserName(userName, session):
  return session.query(User).filter(User.userName == userName).count()

I could test it using this:

  session = mockSession()
  session.query('').filter('')._count = 0 #Initialize the mock session so it returns 0 from count()

  getCountOfUsersByUserName('sadas', session)

And boom, you have mocking in ten minutes or less or your code is free.

As you can see, the highly dynamic nature of Python makes it a great fit for any project that will need unit tests and mocking. And which project doesn’t? You know what I’m sayin’? You now what I’m saying’? High five!

Note: dynamicObject is …. nothing but a cheesy class that inherits Object but has nothing on it. (Turns out that if I did someObject = Object() I couldn’t do this since Object by default doesn’t contain the ability to add things dynamically… and this was by design.)

And yes, I just quoted myself. I am that awesome.