Home > Articles > Programming

This chapter is from the book

Practice, Practice, Practice

How it is done is as important as getting it done. If we want to be good at writing quality code, we need to practice how to write quality code. There is no other way. When practicing, the focus should be on the techniques we are using and not in solving the problem. Solving problems is what we are paid for and what we do at work. However, when practicing, we should focus on how we are solving the problem. For example, imagine you are trying to learn or get better at Test-Driven Development. This is a hard discipline to master. It is counterintuitive at first, and that is why we need to practice.

Do you remember when you were learning how to drive? I remember that every time I was driving up a hill I was praying for the traffic light not to go red. I used to think to myself, “Damn, I’ll need to stop, put it in first gear, release the clutch slowly, and be careful that the car does not stall or roll backward.” I also remember the first time I had some friends in the car and they were asking me, “Can you switch the radio on?” and I, nervously glancing between all the mirrors, firmly gripping the steering wheel, would tell them “no.” That happened because when I was learning how to drive, I was worried about the car. I was worried about the gear shifting. I was worried about the mirrors, other cars, driving straight and staying in the lane, not driving into the other lane when turning, and so on. I could not divert my attention to switch the radio on. Now, after a few years, imagine how you drive. We do not even remember we are in a car. We do not think about the mechanics of driving a car anymore. We just focus on where we are going, what we are going to do when we arrive there; we listen to music, sing along, have conversations while driving. Driving a car became second nature and the car is now almost an extension of our own bodies.

Technical practices and new technologies are the same thing. The more we practice, the more comfortable we become, to the point where we don’t think about them anymore. We just focus on what we want to do with them.

When practicing, we need to focus on writing the best code we could possibly write. If it takes us minutes or even a few hours, to write a single test but it is the best test we could have written, that is OK. We should not worry if we take a long time to name a variable, method, or class. As long as we tried our best to find the most appropriate name for it, we should feel great. We are practicing and when we do it, we should strive for perfect practice. With this approach, when facing the demands of a real software project, we can concentrate on finding a good solution to the problem and not on how to write tests or which commands to use.

Katas

Katas are simple coding exercises. They have a simple problem domain that can be understood in a few minutes and are complicated enough not to be solved too quickly. They normally take from a few minutes to a few hours to be solved and are a perfect way to try new techniques and approaches. An example would be a kata where we need to calculate the score of a bowling game or implement tic-tac-toe. We can use these katas to practice things we think we are not very good at, like Test-Driven Development, another language, or a framework.

Katas have been criticized by certain people in the Agile community, though. Some people say that it is plain stupid to do the same thing over and over again. Well, to a certain extent there is some degree of truth to it. Usually this is said because the term comes from martial arts and that is how it is done in karate, for example. We do the same movements over and over again. That was probably the original intent when we started using the term kata for a coding exercise. However, solving katas with our current toolkit (the techniques and tools that we are comfortable with) does not make a lot of sense.

When doing katas, the idea is that we stretch ourselves, using practices, techniques, and technologies that we are not very comfortable with, with the intent of getting better at them. After practicing these things quite a few times, you may feel ready or at least fairly comfortable with doing that in a professional environment. Think about musicians who practice for hours, days, and months before their live performances. That is exactly what we are trying to achieve here.

Katas can be very beneficial when the same kata is done over and over again but using a completely different approach or technique each time. That allows us to experiment and compare. The correct word to define this practice, according to martial arts, is keiko. However, as developers all over the world have already adopted the word kata, we should keep using it instead of introducing another term.

We can find a good source of coding katas at codingkata.org, codekata.pragprog.com, and kata.softwarecraftsmanship.org.

Pet Projects

Pet projects are for me, by far, the best way to learn and practice. A pet project is a real project but without pressure. There are no deadlines, they do not need to make money, you control the requirements, and, most important, you use the technologies and methodologies you want, whenever you want, wherever you want. You are the boss. In real projects, a professional software developer would first understand the problem domain, then make technical decisions and write code. We would speak to stakeholders, product owners, users, business, marketing, and whoever else is involved and could contribute to the business idea. These conversations, in a healthy Agile environment, should happen frequently throughout the project. According to what the customer wants to achieve and the scope of the project, we would then choose the most suitable technologies to develop the project. Pet projects are exactly the opposite. First we decide what we want to learn—practices, disciplines, methodologies, and technologies—and then we find a problem to solve. It is much easier to understand why and how we can or cannot use certain technologies if we have a pet project to try them out. Pet projects allow us to play, experiment, discover, and learn in a very safe environment, giving us the experience we need to apply what we have learned to real projects.

Another important thing about pet projects is that we can experience several aspects of a real project. For example, we need to come up with an idea. Once we have an idea, we need to start refining the features and preparing a backlog. Preparing a backlog means thinking about priorities, making rough estimations, writing stories, and splitting tasks. We also need to think about tests, how we are going to deploy the application, version control, continuous integration, usability, the user interface, infrastructure code, design, and databases. As soon as we start using the application ourselves, we start changing our minds about the features (business) and also the technology choices. And that is exactly what happens in a real project. We do not need to have all that in place, but we can if we want to. We can use pet projects to learn any aspect of a real project. We can even try to write a business plan for it if we want to learn something about that. Remember, we are the bosses and we do whatever we want, as long as we are learning something. That’s the whole point.

Above all, pet projects are meant to be fun. A common problem that developers have with pet projects is finding a good idea. The good news is that you do not need one. You are not starting a new business. I always advise developers to choose a subject that they are very passionate about. For example, if you like traveling, try to create a website about travel. If you like running, create an application that can capture your progress, display graphics, and so forth. If you feel you should be more organized with your own tasks, create a mobile app where you can track what you need to do. It does not matter if there are thousands of other applications that do the same. There are always different things you would like them to do. The advantage of choosing a topic you are passionate about is that you will never run out of ideas for features or improvements. Besides that, you will always want to work on it since you usually will want to use it as well. All these things will help you to be quite close to a real project, and practicing them will have an enormous impact on your professional career.

A common question is if we should transform our pet projects into a real business. The answer is, “It depends.” I normally would say no to that since if you want to have a business, writing code and learning new technologies should not be your number one priority. I would recommend that you find some good material and get yourself familiar with Lean startup concepts before writing a single line of code. The transition from a pet project to a real business can be extremely painful and full of disappointments. Believe me, I’ve tried it myself. Many of us get very attached to our own applications and code base, which can blind us to what the market really wants. If we feel we should transform our little Frankenstein pet project into a business, focus on the business first and be ready to throw whatever percentage of what you have written away if that is what the business demands. Detach yourself from the code, clean it up, and leave just the bare minimum to satisfy the business needs.

Open Source

Contributing to open source projects is also a great way to practice. There are thousands of them out there. Find a project that is related to what you want to learn or know more about, and download the source code. Start running and reading the tests, if any exist. Inspect, debug, and play with the code. If you want to contribute, start small: add some documentation, write some tests, check the list of bugs to be fixed or features to be implemented, pick a simple task, and give it a try. You can also propose and implement a new small feature to start with.

Open source projects tend to be very different from pet projects because they are usually, with few exceptions, very specific in scope. For example, it may be an object-relational mapper (ORM) framework, a library to make web service calls, transaction management, a social network integrator, and so on. Although all these things are extremely important, necessary, and useful, open source projects tend to be just one of the libraries your professional applications will use, so do not forget to look at the whole picture.

Another great thing about open source projects is to see great developers in action. Looking at how they code and solve problems can be a great way to learn how to code well. Besides all that, it is also a great way to raise your public profile.

Pair Programming

Pair programming is more a social activity than a technical practice. It enhances the team spirit and brings developers together. Many developers are afraid to try it or think they will feel uncomfortable when pairing with others. Many years ago, I used to think like that but I realized that, in reality, I was afraid to expose my own limitations. If that is how you feel, the best advice is to get over it. There is a limit to what we can learn on our own. Of course we can learn whatever we want because we are all very smart people, but the problem is the amount of time that it can take. In addition, we will always have a naive and biased opinion when we are doing things on our own.

When pair programming, we can learn how to use a new language or parts of the application to which we had no previous exposure, a technical practice like Test-Driven Development, a few keyboard shortcuts, or even a completely new way to solve problems. Pairing can lead to very interesting discussions. It can help us to validate our own ideas or have them challenged, forcing us to rethink why we do things the way we do. It also can be a very humbling experience. Usually, we think of ourselves as very good developers, and we like to think that all the other developers are bad. Other developers write crap code, not us. When pairing, we get immediate feedback on our code and ideas. Our pair validates whatever we type immediately. Whenever our pair does not understand what we are doing, or does not agree with a variable name, the use of an application programming interface (API), or a design decision, we have an opportunity to step back and reevaluate the decision. Instead of thinking that the other person is stupid (which is rarely the case), we should think that we are probably not as good as we think we are. A good developer is a developer who can write code that any other developer can understand. When our pairs don’t agree or don’t understand what we are doing, we should take this as an opportunity to have a good discussion. Use it to learn something new and open your mind to different approaches. If someone is questioning what we’ve just done, maybe it is because it’s not good enough and there is a better way of doing it. We should take opportunities like that to share what we know, making everyone around us better. When teaching, we are forced to structure our thoughts, making us really understand our quite often half-baked ideas so we can make someone else understand them.

Pairing with someone from our team or a friend is great, but pairing with someone that we barely know can be even better. Usually team members and friends, after some time working and pairing together, develop a common understanding and style of coding. When pairing with people we have never paired with before, we end up potentially exposing ourselves to very different ways to solve and think about problems. The best way to find different pairing partners is attending meetings organized by our local user groups or technical communities. There are also an increasing number of developers willing to set up remote pair-programming sessions in whatever we want to work with. There are plenty of tools out there that can make a remote pairing session very smooth.

We need to keep our minds open to new ideas when pairing. Sometimes we learn, sometimes we teach, and sometimes we do both.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020