Wednesday, August 20, 2014

DimeCasts.net Redesign - Part 1 - Getting to Know OS X Mavericks














The Current State of DimeCasts.net

Dimecasts.net (a personal pet project of mine outside my daily job) as it stands right now is a site that has been sitting there, stuck in time.  It's had static cast content that has not been updated with new content in more than 2 years, as the site had been untouched after 2012 by previous owner Derik Whittaker who had since then become busy doing other things such as now he's doing videos for Pluralsite, more blog posting, speaking, kids, job, etc.

As it stands right now the production site stack is the following:

  • ASP.NET MVC 1.0
  • NHibernate
  • SQL Server 2005
  • Tables drive the structure of the website
  • jQuery (very old version)

Redesign of DimeCasts.net

One of the goals of redesigning DimeCasts.net was to venture out of the Microsoft world including code.  I've worked a lot with Subversion, a little Git, some Dojo on the job, etc. but there's a ton out there and things are so much different now that it's a shame I'm still stuck in only .NET and MS tools mainly in the jobs I've been taking.  In fact I've tried very much to stayed away from painful tools like TFS, and others that are simply bloated and get in your way rather than make it easy for you to get your job done.  One would not know the pain one is dealing with in TFS unless they have ventured out and used other tools like Subversion, Git, etc.  

Most .NET devs look at me like are you crazy, TFS sucks?  Then I ask them is that all you've ever used?  It's usually "yes" OR "I tried subversion or Git and it's not good, it sucks, or it's hard".  That's just like saying "Resharper is no use" which both are completely bogus statements to be making.  If you haven't tried to use a tool like Subversion, ReSharper for more than a day before you give up, then don't tell me TFS is the bomb either.

I wanted to get more versed in stuff like Node.js, Angular.js, Express for Node.js, Grunt, Jasmine Test Runner, etc.  And what better personal project and opportunity to apply that than Dimecasts.

And one of the main things was I'm gonna do this using the Mac OS.  Yes you can run node in Windows but I want to know how the rest of the world does hit outside Microsoft.  So I am forcing myself to use the Mac OS for redesigning Dimecasts.net.  So this first post is about just getting around and my feet web in the OS.

As I started to use OSX Mavericks, I was pleasantly surprised at what a nice operating system this is.  Previously  I was in the boat of "Mac OS sucks" which is what most .NET devs will bitch about and run away from.  However, sometimes we have to open our eyes and stop making statements that are totally outdated and monolithic and actually try things again.  After all things have drastically changed since 5+ years ago.  

If you're still naive enough to say the Mac OS sucks, Node.js is puke, and JavaScript is trash, then you are being stubborn and speaking either on heir say or you are not informed when you say these types of comments.  Unfortunately I have to say it, that most .Net devs fall into that bandwagon.  It's sad, and I have realized that there are way more things outside .Net that are far more fun and being used more and more that it's just dumb of me not to get to know it.  I think it's sad that most .NET devs that I know at least are so biased and think that the only thing that should and does live in our world is Microsoft technology.  I'm not saying I don't like C#, ASP.NET MVC and sorts but MS falls short in a lot of tools where others make your life a hell of a lot easier that you could be using with your MS codebase.

When I did Dojo & Dojo MVC a couple years ago, it opened my eyes to what a JS Framework can do for you.  Granted Dojo is the older JS framework and less desired now that there are frameworks like AngularJS, Backbone, whatever but Dojo had apparently been drastically redesigned and now uses some of what most JS frameworks have, at least some of it.  

I wouldn't use Dojo as a framework personally but still, it has MVC, etc.  And showed how JS can be elegant and maintainable and fund to code in.  These frameworks show the power of JS.  Ok, ok for those of you who must have a T-Shirt that says "JS sucks", again, don't be so naive.  Yes it's a bit of a pain to debug but try out a framework, you'll find JS can actually be decent even though it's not a typed language.  That's where you need to again open your eyes and install tools like Webstorm, IntelliJ, etc. that have super rich intellisense that will drastically change how you debug and code in JS and make a lot of the chores an d pains of coding in this language melt away.

Remember, jQuery is not a framework, it's a JS Library, those are 2 completely different things with different purposes and uses, but both can be used together of course to create powerful websites.  jQuery can live on top of a JS framework Views to provide additional functionality, but it doesn't provide an MVC framework, stuff like Angular and other serious JS Frameworks provide you.

Don't get me wrong, we'll still be looking to add a ton more casts around .NET technology but we're also looking for casts on a slew of other code subjects outside MS as well now.

OS X Mavericks

One of the first things I missed form Windows (I am running Windows 8 dual on this Macbook Pro BTW) was OneNote because I put a ton of information and notes about code as I come across stuff I want to revisit or have handy, errors I've come across and how I resolved them, family and personal info, you name it.

One of the first wins after venturing around in the Mac OSX was I found out that OneNote is FREE through the app store which rocks.

After installing OneNote, I was ready to rock and roll because now I could document and create screen shots of stuff for both blogging and just for remember wtf I did in my journey to recoding this great site.

Second, being a Mac OS n00b, I noticed that Ctrl + C is not a shortcut in the MacOS for copy.   Not to mention you scroll in the opposite direction in the Mac OS in order to go up and down compared to what I'm used to in Windows.

Third, I wanted to get a pic off my DimeCasts twitter page to put in this blog post.  In windows 8, all I had to do was to use the OneNote very handy screen capture tool that lets you drag and select an area of your screen and then puts that into your clipboard for you...very convenient.  I thought to myself hmm, where is their image editor and how can I copy full or partial parts of my screen to the clipboard? TBH, other than of course resorting to searching the net, there was nothing in the apps or utilities list in the OS that yelled out at me as "Hey I'm an Image Editor!"....or "hey you can use me to capture parts or your entire screen".  I didn't even know how to print screen in the Mac OS.  So I started to get to know the Mac OS Maverick Shortcuts.  And then how would I get that image from my clipboard and into a file so that I could work with it in a graphic editing program?  And I quickly found out by doing a search that Preview is the default image viewer & editor in the Mac OS for image editing.

So far, other than finding an image editor and how to work with the clipboard and screen capture, the journey has been smooth.  

Stay tuned for Part 2.

Thursday, August 14, 2014

The Pressure to Deliver Value to the Business





ohhhhhhh I love this phrase 

because it's one I've heard myself before myself:

 "I know you’re capable of doing this." 

This blog post from 8th light called Honesty Under Pressure turned on a light in my head and got me going because I can totally relate to these types of comments I might get as a developer.

This kind of phrase gives me the image of a manager pounding down on that Staples "It's easy" button.

Lets be honest, that phrase is a sales pitch and command to cut corners.  It usually translates directly to "I want you to cut corners, we don't have to be perfect, we can skip core principals that we feel only has to be done half the time, and so lets get this out the door and provide business value" type of nonsense.  If you hear that too often, it demotivates you if you are a developer who cares about speed AND quality.  And it can drive a team culture away from quality.

"Capable" should never correlate to JUST speed.  It's about being capable by doing it WELL.  We are capable of doing anything.  We are capable of rushing and creating poor quality, or we can be capable of going fast with quality.  Sometimes you need to slow down instead of speeding up, as hard as it is for that person to swallow.

We want to be fast with quality at all times.  For some developers, it's in their very nature to care, and to be passionate about providing quality at all times in addition to speed.  Quality includes refactoring frequently when you see opportunities to make code better, driving code by test (TDD)  where you can, and adding code coverage after where you need to. 

There are times when during a sprint that you discover things.  You discover things about your code when you do both TDD and also refactoring.  Both those bring to light a LOT.  In fact today, we realized a lot when we started to refactor and move stuff into methods and then out to a new class to keep things simple.  We learned that this refactoring that took us a few minutes now allowed us to add code coverage that was not possible before, because that code was in one huge method, or a bunch of unrelated code was all in one large class breaking the the Single Responsibility Principal.  

There are times that we are told to throw in hacks rather than take that 1-5 minutes to refactor.  "You're capable of pasting in slop or skipping code coverage, or capable of skipping refactoring frequently such ignoring the fact that you just saw several cases in the code you just touched where abstracting some of that code out into new methods, a new class, or whatever it is".  I don't accept that as a way to code.

I'd much rather be capable of doing it well AND fast rather than doing it too fast just to put a smile on my boss, PM, and the business's face. 

Honesty

Going back to that blog post from 8th light.  It's true.  Sometimes you have to look in your boss, colleague, or PM's face and be honest.  That no, this story is not going to make it.   Sure it could make it if I copy and paste for you for this last tidbit for this story.  But guess what, I'm not going to copy and paste code everywhere, sorry, It may take a few more hours.  Because I care about quality and maybe we had some unexpected delays, or something took longer than we had estimated.

Don't be scared to do that.  Communicate it as early as you can, but take pride in the fact that you didn't just rush it to get it out the door, you slowed down and made sure that quality is always the outcome.

If quality is what you want out of your developers, don't say sentences like that.  And Developers if you are ones who care about quality, don't accept that kind of statement.

Value

My definition of value in software development includes speed and quality which translates to a lot of things including maintainability, readability, speed, test-ability, and simplicity of code.   I do not cut off the later, I do not cut off quality.

Simplicity 

Simplicity comes from looking at your code every small step of the way (I do this a lot when I TDD), refactoring along the way, and keeping things simple.  Simplicity is when you name methods, classes, and variables to make total sense in that they imply exactly what they do.  Simple is adhering to the SOLID principals, especially Single Responsiblity.  Refactoring allows you to keep things simple as well and reusable.  

These are all attributes that make up value to the business, your team, and ultimately your family because you can go home at the end of the day because you don't work in a mess, you work in code that has been crafted by developers who care about the code they write and the code they write for others to consume or extend.

Quality 

Contrary to status quo, is not as "relative" as a term as you may think.   Software Craftsmanship is also not as relative term as some think.   Some people will try to minimize the term Quality and Craftsmanship just to get you to speed up too often and too much.

Quality can be measured 

How so?  well some examples are by # of bugs, % of of code coverage, and usability (speed, simplicity, navigation, etc.) of your application as a whole to other developers and end users who consume or use the application you write.

Use Tools and Defend Claims on Time

I use tools to make my life easier.  For example ReSharper.  I can prove that Visual Studio doesn't provide the same that ReSharper does and that it matters.  I have become a much quicker programmer because of this tool.

Therefore when I refactor it's usually 2-3x as quick as someone who doesn't have a tool like ReSharper in many cases.  So they end up pointing out that you took too much time moving some stuff out into a new class.  

You know it didn't.  Stand up to that and let them know.  Correct them and tell them that hey, it did not take that amount of time because I use templates, or I use this tool or that. 

Don't let someone dictate to you that you took too much time when they have no idea and were not there when you actually did that refactoring!  How do they know?

Don't Feel Bad, Don't Worry, Keep Your Head Up

I'm not always the popular guy on some teams.  

"Hey did you drive that with TDD or did you add code coverage to that existing code"

"Hey, lets move that set of code out into some methods, it's hard to read and it's doing way too much here"

"Hey lets break this method out now, not later"

"Hey what do you think about renaming that variable to make more sense"

Don't feel bad or Timid About Pushing for Quality

Explain the benefit the best you can, but don't let someone try to shut you up if you want to voice a concern around it.

Try not to drag out the conversation but certainly don't go run and hide under the rock because a particular teammate always likes to rush.

I can tell you that when I pair with those who care about quality, we have very very quick conversations throughout the day, every day.  We might have 10-20 second conversations while we pair quite often.  But that's good, because you are both striving to maintain quality around small units.

And I've noticed that when I pair with people who do not care enough about quality, the opposite happens usually.  You're pressured to continually rush.  And these are people who don't care about learning either.  They don't care about having small conversations to gain the benefit of learning as well, one of the benefits of pairing.  That's not the kind of pressure you want to have constantly on a team if you want a culture that drives quality in your organization.  These kinds of devs belong in a culture that fits them, somewhere else if not willing to change.

Quality is Hard

First off it's both a people thing, and it's a code thing...balancing of each.  It's hard to get people who are lazy in the bad sense if the word to care more about quality.  And likewise, It's hard to learn to be a better communicator to help advocate quality and show benefits where you can.  It's hard.  But please don't be that developer who wants to always be be lazy in the bad sense of the term.

And each and every one of us should try to become better coder as well.  I am always learning.

Always Strive to Get Better Driven by Quality

When you strive for Quality, you  get better as a developer.  When you do not strive for quality, you become a complacent developer.

Don't you want to continually learn and become a better developer?  Let the goal of pursuing quality drive that.

Cutting Corners & Code Rot


Should we cut corners?  Lets be realistic, sure we have to sometimes.  But it's how many corners you are cutting, how often, and in what situations/reasons.  Always look to refactor often in small amounts...never all at the end.  Because when you keep your code simple, refactor often, you find that there are less corners to cut and when you do decide to cut corners, they're minimal.

Be careful about cutting corners.  Some devs like to cut corners a lot. I think some devs feel good when they cut a lot of corners just because they were able to tell their boss it was done or that they can clock out at 5pm.

But ask yourself every time, is it going to make the code harder to deal with next time?  Is it going to perform horribly?  Can you read it?  Every little corner you cut counts and as a whole these corners cut have a huge effect on the amount of code rot in your application.  Too many corners cut can have the effect of forcing or persuading other developers to cut those corners too when they see that being done often.  

No you don't always have to debate it with them but if you feel strongly that cutting a particular corner (as simple as it may be to them), might be bad for the code speak up.  Have a constructive conversation around it.  You'd be surprised, usually you learn something half the time and change your own mind half the time and even wrong sometimes!

Trade-Offs / Compromise

Yes there are trade-offs and compromises that you might have to make.  

I'm not saying you need to be debating everything.  

For example, maybe in a class you originally thought it would be better to create a bunch of overloaded methods instead of cramming all params into one method including optional params.  Maybe you see the trade-off as making the decision to go a head and stuffing more params into a method even though you know it might make that method less desirable because you may have a bunch of if statements in it, more than you're usually comfortable with as a lot of logic usually means you're violating SRP and your method is doing too much.   I made that trade-off recently with a collegue, even though inside it felt gross.

But just don't make trade-offs always a split decision without at least thinking about it.   Don't let someone push you to skip your thoughts.  I've seen that happen a lot.  There are developers who will do that.  They'll continually cut a ton of corners and not question even their own trade-off just because they're dancing around because they just care about speed only.

Dates are just Estimates

Don't let a hard date deter you from driving code based on quality.  Yes we try to hit the dates we give don't get me wrong and we should try very hard to hit those dates always.  However, don't let the hard date be the end all if you feel quality is not there.


Professionals

We did not go to college just to come out of it, get a job, and then care only about codeing as fast as we as the ultimate factor of success.  

We are not Part-Time Professionals

There is no "we can care about quality half the time and the other half can be copy and paste, or that 100 line method can just sit there, we don't need to break it up, that small 2 minute refactoring is just unnecessary and waste of time".  There is no part-time quality.  You either care about it at all times or you do not...period.  That's why I see developers as black and white.  There is no grey.  And there should not be a grey.

We are professionals, not hackers.  We deliver business value fast, but learn together and figure out how to do that with quality every step of the way as we code to deliver this ever so sacred term "value" to the business.

As professional developers, we should be learning from each other and expect quality from each other as developers at all times.  If less experienced developers don't understand how to bake in quality code yet, help help them to when you see those places that can be made better.