General

Code Lint – What is it? What can help?

Code Lint – What is it? What can help?

So what exactly is code lint?  I’m sure we’ve all heard of a linter but how many out there have actually taken the time to sit down and use one?  What are they used for?  Well, getting rid of code lint, of course!  A linter is defined by Wikipedia as:

A linter or lint refers to tools that analyze source code to flag programming errors, bugs, stylistic errors, and suspicious constructs.

So obviously feeding off of the definition of a linter, a good explanation for the lint itself could possibly be clearly defined as:

Code lint is a software programming “smell” that is identified by programming errors, bugs, stylistic errors and/or suspicious constructs.

I personally believe that this is a good explanation to those.  There are linters out there for nearly every language, however; I’m going to focus on JavaScript for soon-to-be apparent reasons.

Continue reading →

Posted by DCCoder in Design and Best Practice, Programming, 0 comments
Building a self-hosted API with OWIN

Building a self-hosted API with OWIN

So it’s Friday and I haven’t published anything this week yet.  Figured I’d push out a short and quick tutorial on OWIN and give everyone something to play with over the weekend!

What is Owin?

OWIN is an acronym that stands for Open Web Interface for .NET and is meant to define a standard interface between web servers and applications. The goal of OWIN is to decouple servers and applications.  Due to this it encourages the development of simple modules for .NET web development.  Because of this OWIN is great for building small, simple, self-hosted applications.  It’s ability really shines when it comes to the creation of micro-service APIs.  Within this tutorial I will take you through the basic process of creating a small self-hosted API.  We will go from inception all the way to implementation and discuss possible use cases.

Continue reading →

Posted by DCCoder in Tutorials, 0 comments
Why I don’t post on the weekends

Why I don’t post on the weekends

I do my best to continue to push content and well-written, informative, articles out to my subscribers.  You may,  or may not, have noticed that no content goes out on the weekends.  Aside from maybe the odd pre-scheduled post.  The reason behind this is because, like many others, I too am susceptible to burn-out.  So what is this burn-out?  Well it’s basically a type of stress that leads to:

  • Physical, mental, and emotional exhaustion
  • Cynicism and detachment
  • Feelings of ineffectiveness and lack of accomplishment

In other words, you will stop caring and lose all motivation.  I have personally experienced burn-out many times.  One of the worst times it got me lasted over a year.  Probably one of the worst things about burn-out is while you may want to push forward and just “get through it”, that has the adverse effect.  There are many well-written articles on this topic, and on how to combat it.  I personally try to simply limit my work to weekdays and focus solely on Family and friends during the weekend.

Taking this approach helps me keep my priorities straight.  This includes both my personal and professional life.  Burn-out is a very serious threat, especially to those of us in IT.  Quite frequently our hobby and our living coincide.  This typically means that 8-5 we are working, 5-11 we are still working (just on personal projects), and 11-7 we are dreaming of work.  I love what I do just as much as the rest but to say the human mind isn’t built for that is an understatement.  Step back from work and find, completely unrelated, hobbies.  Spend time with family, or outside.

This is exactly why I don’t post on the weekends.  I stay away from any form of work and just enjoy life.  This helps me step back into each Monday with a fresh and clear head.

Posted by DCCoder in General, Personal, 0 comments
Hello C# 8, goodbye null reference!

Hello C# 8, goodbye null reference!

Say hello to C# 8.0 and goodbye to those nasty little null-reference exceptions!   That’s right, Microsoft is getting ready to release yet another major version of the language!  This has been common knowledge for a little while now, so I may be slightly behind.  Behind or not, I still wanted to bring it up.  I am excited about all of the changes and features coming in the new C#.  I don’t have the time or the space here to cover all of them but I will touch on some of the most drastic and useful features being added in.

 

Null references

Brace Yourself, NullRef Exception incoming

Let’s face it, we’ve all been there.  Everything compiles, we run our program eagerly awaiting it’s output.  Then BAM!  A big nope screen is thrown in your face, saying something about a NullReferenceException.  Believe it or not Null References were suppose to be a thing of the past a long time ago.  Thankfully the C# designers have finally gotten around to trying to get rid of them.   Currently by default all reference types as well as variable types are nullable, this is all about to change.

Non-nullable by default

Starting with C# 8.0 reference types, by default, will be non-nullable.  Now this isn’t to say that you can’t make them that if you so choose, but again this is by default.  The C# compiler is also going to help you on this quest by throwing some helpful warnings if you forget to check for nulls or forget to make them nullable.   Take a look at the example below:

 

1
2
3
4
5
ISomeType notNull;
ISomeType? mayBeNull;

notNull = null; //This will throw a compile warning
mayBeNull = null; //This won't

Another nice aspect about this is now it will also throw a warning if you forget to check if a nullable is actually null. This is a feature I believe is going to come in very handy. Take a look below:

1
2
3
4
5
6
7
8
9
ISomeType notNull = GetSomeType();
ISomeType? mayBeNull; = GetSomeType();

mayBeNull.Execute(); //This will throw a warning (we didn't make sure it wasn't null!)
notNull.Execute(); //This will run fine

if(mayBeNull !=null){
  mayBeNull.Execute(); //This won't throw a warning (because we checked)
}

 

Records

I’m sure most of us have worked with POCOs, creating numerous classes that are simply just going to be used to define a data structure and hold it.  Traditionally this meant writing out a whole new class and defining it’s properties.  Thanks to C# 8.0 we now have records!  With records you can easily and quickly create these “container classes” with one line of code!  For example, instead of having to type of this:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public class Person: IEquatable<Person>{
  public string FirstName { get; }
  public string LastName { get; }

  public Person(string firstName, string lastName){
    this.FirstName = firstName;
    this.LastName = lastName;
  }

  public bool Equals (Person other){
    return Equals(FirstName, other.FirstName) && Equals(LastName, other.LastName);
  }

  public override bool Equals(object obj){
    return (obj as Person)?.Equals(this) == true;
  }

  public override int GetHashCode(){
    return FirstName.GetHashCode() + LastName.GetHashCode();
  }

  public void Deconstruct(out string FirstName, out string LastName){
    FirstName = this.FirstName;
    LastName = this.LastName;
  }
}

 

Now you can just do this and get the same results!

1
public class Person(string FirstName, string LastName);

Now, I don’t know about you but this is definitely one of the more helpful features that I’ve seen.

 

And many more!

 

These are just two examples that I decided to speak on simply because I find them fascinating but there are many other features in C# 8.0!  Check out the links below to find out more!

3 New C# 8 Features We Are Excited About

Posted by DCCoder in News, Programming, 0 comments
How to get started blogging?

How to get started blogging?

Throughout my many years on this earth I have tried my hand at blogging. And to be honest, I had no idea what I was doing.  I see a lot of my peers beginning their blogs, trying to build a personal brand.  But nearly all seem to be lacking (and I’m not excluding myself).   Building a personal brand is one of the easiest ways of advancing your career.  But what constitutes a good blog?  How do I get started?  If you’re like me, the first thing you do when a question arises is google it.

Continue reading →

Posted by DCCoder in General, Personal, 0 comments
Comments are useless, sometimes evil!

Comments are useless, sometimes evil!

That’s right, I said it. Comments are evil. But wait a minute, I hear you say, they tell us about the code, help us explain what is going on, etc etc.  I’m not saying comments can’t be useful in code, of course they can, but that vast majority are not.  Most that I have seen are simply useless and some are even downright evil.

“Code never lies, comments sometimes do.” – Ron Jeffries

Continue reading →

Posted by DCCoder in Design and Best Practice, General, 0 comments
Material design, what is it and why you should be using it.

Material design, what is it and why you should be using it.

Lately there has been a lot of uptick in Material Design.  More bloggers are blogging, and more designers are designing, but as a developer what do you need to know about Material Design?  The best place to start is to define exactly what Material Design is.  Wikipedia defines this as:

 

Material Design (codenamed Quantum Paper) is a design language developed in 2014 by Google. Expanding upon the “card” motifs that debuted in Google Now, Material Design makes more liberal use of grid-based layouts, responsive animations and transitions, padding, and depth effects such as lighting and shadows.

Though this description technically does describe it, we can do a little better.  Material Design is a design language that focuses on “materials” or objects with physical surfaces and edges.  This was primarily created with mobile application design in mind. These days, however, Material Design is being extrapolated into many other realms such as web development.

Continue reading →

Posted by DCCoder in Design and Best Practice, 0 comments
Automated UI testing with Selenium [Part 2]

Automated UI testing with Selenium [Part 2]

In Part 1 we set up Selenium and created our first test showing a browser being opened and then immediately closing.  While that was interesting, I don’t know many people that would be super exciting by that alone.  Since the whole point of these tutorials is UI testing, why don’t we actually test a UI?  In this article we’re going to walk through creating a few more tests to actually log in to a website and verify that only a user with the right credentials can log in, we don’t want just anyone logging in now do we?

Continue reading →

Posted by DCCoder in Programming, Tutorials, 0 comments
Automated UI testing with Selenium

Automated UI testing with Selenium

It seems everyone is making the move towards automated testing these days, and why shouldn’t they? How many times have you been working on a web project and had to constantly retest the same thing over and over simply to verify that it works? Or maybe you’re an analyst on the surface but a code monkey at heart and would like to blend the two together? Enter Selenium.

What is Selenium? Selenium is a browser automation framework. I was exposed to it a few years ago when I was still heaving into web scraping. Selenium is perfect for UI testing as it can easily mimic an actual browser with human input. You can even change the type of browser you want! Ok, so hopefully by this point you’re interested (or maybe not) and want to get started.

Continue reading →

Posted by DCCoder in Programming, Tutorials, 0 comments
Local Events

Local Events

Living here on the Gulf Coast there is usually a lack of technical meetings, talks, and conferences. The ones that are out there are usually difficult to locate and hidden behind various websites. Due to this and my attempts to further the local IT community I will be posting all local events I come across to my blog. You can find the upcoming ones on the right hand side, or visit the Events page to see the full calendar.

If you are hosting a local IT event and would like me to post it up, just reach out to me via the Contact page.

Posted by DCCoder in Personal, 0 comments