Month: December 2014

Hood.ie

Hoodie, Part 2 – Our First Custom Hoodie

Last time, we got Hoodie installed and made the first simple application. If you had done it correctly, you would have been able to add ToDo’s and then remove them by clicking them. Let’s make another application, and while Hoodie supports templates to create applications, I’m just going to have it make the default application again and we’ll replace what we don’t need.

I’m going to type hoodie new part2 and create a new application called part2. Here is the result:

Our new part2 app

If we do issue a cd part2 command, we end up inside the application folder. Let’s take a look at what file are contained in the folder by default.

  • README.md – Contains information about the application, how to get started, and even how to deploy the application
  • package.json – As you can probably tell by the installation process we had to follow last time, Hoodie applications are really just Node.js applications and Node.js apps need a package.json file. We get the name of the app here as well as the list of dependencies that it needs to keep up to date and deploy.
  • node_modules folder – Another fairly self-explanatory one. This folder is where npm actually keeps the files needed for the application. If this was regular Node.js application, we might just get the package.json file from source, and need to call npm install in order to get this folder and its contents, but the hoodie new command did that
  • data folder – This folder is our database. You actually won’t see it the first time, but instead it is created the first time you run hoodie start. If you want to easily wipe out everything for the app, renaming or deleting this folder will cause a brand new database to be created.
  • www folder – Everything for the application, asset-wise, is here. All HTML, CSS, JS, images, etc live in this folder. Treat this like any other web root, Hoodie doesn’t do anything to new files in here that would cause you to lose your work.

I’m going to leave the application intact and we are going to just make a new file inside for our demonstration. All we really need to make the HTML file we are creating “hoodie-able” is to include this script:

<script src="/_api/_files/hoodie.js"><script>

If you go digging around our directory, you aren’t going to find that file at all. The reason is because the Hoodie server serves that file up dynamically by itself. Not only is the goodness of Hoodie in this file, but it also has the front-end code required to work with any of the plugins that you’ve installed along with the app.

The first thing I’m going to do is add a new file in the /www directory called new_user.html. Here are the contents of that file:

I’m also going to create a new file in the /www/assets/js directory called new_user.js. Here are the contents of that file:

The HTML file should be pretty self explanatory. I just made a simple form that takes an email and a password. We include the hoodie script file and our own script file and jQuery. If you call hoodie start and give it a password for the application (first time only), you will get the default screen that we had before.

Our JS file shouldn’t need too much explanation, but there are some things that are likely new to you. The “use strict” is something new in ECMAScript v5 and it forces you to write better javascript. Here is some documentation if you are curious. The next line “var hoodie = new Hoodie();” instantiates the Hoodie object.

After that, we have a block of code that is wrapped inside of the jQuery document ready method. Much of the code is concerned with trapping variables and manipulating the screen, but we should be interested in the two lines that are “Hoodie-centric”.

hoodie.account.signUp(username, password).done(function (user) {checkUser();});

hoodie.account.signOut().done(function (user) {checkUser();});

Our hoodie variable that we declared earlier has an account property that accesses the account store inside of the CouchDB instance. Account has signUp(), signIn(), signOut(), changeUsername(), resetPassword(), and changePassword() methods that you can call. The signUp() and signOut() methods also allow you to provide a callback, which we did and used to manipulate the DOM. All very simple and basic, which is definitely what the Hoodie developers were trying to accomplish.

If you now go to http://127.0.0.1:6007/new_user.html (your port could vary, check the console as you start), you will see a screen like this:

Hoodie Part 2 New User Form
(ignore the symbols in the textboxes to the right, that is LastPass being helpful)

When I put in an email and password, and click register, I get logged in and greeted.

Our Filled-In Form

Signed In

Clicking Sign out gets us back to where we were:

Signed Out

So, what did we do? Did we really just create an account? Go back to the main page, for me that is http://127.0.0.1:6007, and go to the upper right hand corner, hit the drop down arrow and choose to sign in.

Main Page Sign In Button

You will be presented with a form. Put in the information that you registered with on our page.

Main Page Sign In

You will now be shown as signed in. We really did create an account.

Main Page Sign In Successful

That’s it for this time. Next time, we’ll try creating some custom objects and see how easy (or hard) that is with Hoodie.

Book Reviews

Soft Skills: The Software Developer’s Life Manual

Soft Skills CoverSoft Skills are extremely important for developers. Ever since Brian Prince created a Soft Skills series and gave similar talks at conferences, I’ve been made aware of the term “Soft Skills” and why they are important for developers. Too many technologists focus only on coding skills and not on the other things that you need to know in order to advance your career in companies that are staffed by (believe it or not) human beings.

I even cover a few soft skills that you need in order to be considered a “professional” in my last podcast, because I think they are that important. So, when I heard John Sonmez talk on the Entreprogrammers podcast about this book, I knew I had to check it out.

The book is called Soft Skills: The software developer’s life manual, and it is a great addition to every technical person’s library. Even those who are non-technical could get a lot out of the book, but it does have a target audience of technical individuals.

Soft Skills is written so that it can be read either in one sitting or as a guide to be consulted in times of need. Even if you feel like you “know” a topic, I would still recommend reading the section, because John has such an interesting perspective on each area.

The sections cover Career, Marketing Yourself, Learning, Productivity, Financial, Fitness, and Spirit. No, I didn’t change topics; John does cover money and well-being (mental, physical, and spiritual) in this book. Developers and technical people often live very sedentary lifestyles and build up their minds at the expense of their bodies. John sees no such dichotomy.

I first became familiar with the author from his Simple Programmer blog, his Pluralsight courses, and then from his podcasts and guest podcast appearances. I am a customer of his “How to Market Yourself as a Software Developer” course and this book continues the quality material that he is known for producing. For those who are also customers of that course, there is a little bit of overlap between the course and this book, but nothing that should keep you from buying and reading this book.

Lastly, this book is a great investment. With so many technical books threatening to be out of date before they are finished printing, John Sonmez has authored an instant classic that will be valuable for years to come. Just like Clean Code, The Pragmatic Programmer, and Code Complete, this book is one that you can read and reread in order to continually improve as a person in the workforce.

I highly recommend this book.

Podcasts

Podcast Episode 30 – Being a Professional Programmer

ProfessionalismFor my last episode of 2014, episode 30 has me giving my opinions on what makes someone a programmer. More so, what classifies someone as a “professional” programmer. Is it merely “programming for pay”, or is there something else to it? People on Quora and other places on the Internet have no shortages of opinions, so – of course – I have to weigh in with my own!


Links Mentioned in this Show:
The Question that started me thinking
You Can Charge More, by Andy Adams
Codewords Quarterly

You can also subscribe to the podcast at any of these places:
iTunes Link RSS Feed

Thanks to all the people who listen, and a special thanks to those who have rated me. I really appreciate it.

The episodes have been archived. Click Here to see the archive page.

Business of Software

Podcast Episode 29 – Management, Leadership, and the True Role of a Follower

LeaderIn Episode 29, I take some time to think about the roles of a leader and a manager and how those intersect and how they differ. I not only share from personal experiences of when I’ve had to lead and manage, but I also share some wisdom from my father on the subject. (He’s a lot smarter about it than I am). I also talk about the importance of followers and how following isn’t a dirty word.


Links Mentioned in this Show:
The Pete On Software Podcast on Mentoring
Dash

You can also subscribe to the podcast at any of these places:
iTunes Link RSS Feed

Thanks to all the people who listen, and a special thanks to those who have rated me. I really appreciate it.

The episodes have been archived. Click Here to see the archive page.