A lot of people want to code out of interest or to do some homework and some don't know how to start. I am a seasoned developer and I see a lot of plain questions in this area, so I want to share my knowledge and experience.
The first decision is what to learn by deciding for what you want to develop. If it is your homework, then the task and the language is clear, but when starting a career, a lot of questions are open. Do you have any idea what job you may get?
There are tons of online learning platforms like coursera or OpenHPI.
Search on Youtube for some tutorials with a lot of lessons in programming. Compare some - there are bad, good and some outstanding.
Choosing the Platform
By choosing what software should be developed, often a choice of the tools is made. Most modern IDE are specialized for a platform or operating system.
The tool of choice is Android Studio and to learn it from some video tutorials in this area. The language Java is superceded by Kotlin.
C# and Xamarin
Is a high level language for programming user interface oriented apps in the Windows world. It is more interesting when working for mobile apps with the cross platform tool Xamarin.
If you want to learn programming from scratch, then C and later C++ is the best. Search for some online tutorials. This is a good starter tutorial but the greater Learn C++ tutorial provides broader knowledge even on installing and working with the IDE. For the C language, this C-tutorial is interesting.
With downloading and installing Visual Studio from Microsoft, everybody gets a state-of-art development tool.
But knowing a programming language is only the beginning, because a lot of code and tools need to get applied. Important are code libraries, SDK and tools like git. Here, on CodeProject are a lot of sample projects to discover, some really great.
Some Words about C versus C++
C++ is somehow the "child" of C and is so the same language added with a lot of useful enhancements. This article gives an overview of the differences between C and C++.
If anybody wants to develop software for embedded devices like drivers or integrated circuits, C is the first choice.
The class feature of C++ can somehow be substituted with
structs. Then the
struct is first input parameter in the functions as pointers.
The Apple Universe
If you want to learn programming for Apple like iOS or MacOS, then the first address is https://www.raywenderlich.com/.
I would suggest the paid video plan because it boosts knowledge and learning speed and so is worth the money.
It is most important to know what you want to program, because every target platform has some preferred language. And that is the ultimate decision argument for choosing a language.
Not only Android apps are in Java, but also a lot of server applications are in Java.
Most people underestimate that a lot of software written in legacy languages is still running. I am talking about languages as COBOL, FORTRAN and Visual Basic. Often, employers demand such skills, so it may be worth a look. It is interesting that C# and the net-platform have some interfaces.
How to Start a Project
The first step is to define the solution, often it is the task from the teacher or the managers. The next step is to divide the complex task in complete sub tasks, like user interface, input, networking, computation and output. This leads to codeable pieces of work. My experience is: spending more time in that task leads to a smoother coding process, so it is worth the time. Anybody who must confess that he has re-written his app at the end knows that. Nearly everybody has to learn that lesson the "hard way".
It is always a good idea to search for similar code on the internet. Here, at CodeProject or Github or other vendors, you may find nice examples and some help.
Is the synonym for "lessons learned the hard way". I learned these rules often watching that these rules are avoiding trouble.
When you feel you don't understand the task, you must try to find it out. First places are Wikipedia, Google and Youtube. Often, there is a lot of background knowledge presented because a lot of people had similar problems. If that doesn't help, ask your mates or colleagues and then go to the teacher or manager. Don't wait till it is too late.
Quality Needs Time
Don't write code too fast. First think about some concept of code flow and architecture. Make a concept of your work. At best, you write some prototype code which is mostly complete. It helps to optimize the project structure, so minimizes work load and detects problems. Write clean and accurate code, so reading and debugging it is fun. Take my advice seriously: superior code quality saves times.
Readable Code is Good Code
If the code is short and straightforward, it is good code. Handle the common workflow first and handle errors last. Also use the internal data type and as few macros as possible. This helps the compiler to dig into your code and show you some warnings.
I learned that the hard way: some warning translated into bugs with malfunctions or crashes. So let the compiler be your best friend while coding. It is your only friend when writing code. ;-)
Use code reviews aren't to "grill" you but to learn about weaknesses in your coding and improve your skills. Let collegues or mates read the code and discuss how they understand it and where there is room for improvement. Try to write code in such quality that you like to reuse it later.
Use Standard Wording
Every language has standard wordings for variables, functions and classes. This helps to understand the coding, debugging and maintenance. After months and years, the code stays readable - even for your team mates. Anybody who has fixed a colleague's bug in his vacation time will know it.
Use the English language, because every programmer around the world understands it. Imagine a French and a Chinese coder working on the same code.
Use Functions and Libraries
Tons of code is written and want to run. So take the time to learn the functions, like in C/C++ the libraries and API of the system. For instance, knowing the standard C++ library is fundamental when programming for C++ because it provides the tools to write big parts of any project. No one needs to reinvent these functions which provide excellent multi media libraries as ffmpeg or opencv. The best part is that these functions are tested and run for millions of times, so they are considered to be "bug free" and there is a lot of Q&A on the internet.
Use Standard Tools
Tool chains are available for team work, issue trackers and code backups. So it is best practice to work with tools like git or lint. A developer should have deep knowledge of git and work fluid with it on the console. In every company, such tools are the backbone of the work flow, so use such tools as helpers not as foes.
A code analyzer like lint helps to identify weaknesses or problems which can get solved in an early stage before all code is messy.
Security and Privacy
Is an important issue for the user. No one wants their passwords in a logfile or some private pictures on the internet. So, encrypt important data with modern techniques. Best is to not store what is not really needed.
Be also aware that no user data is send in your analytics or monitoring software. Cut of user data or replace it with some dummy data.
Use Logging Output
Use some output in critical paths of your code. Sometimes, logging on the console is enough, but often writing a log file helps. Keep it short and crisp. Pay attention to privacy. Never ever log sensitive data of the user or its device and network.
The Hard Work
The hard work is often not the writing of the code, but debugging and testing in real world scenarios. It takes time to play around and find the edge case. It is a good idea to give some selected users a beta version to find some "alpha version" problems. They will be there.
Most modern IDE have tools for writing tests. It is stupid to not make use of them.
Whenever possible, write test code and run them often. This keeps the code in a defined quality and saves time. One main advantage is that the test are checking your code, even when somebody else is changing them. See the tests as the first user of your code pieces right at the development process.
A good starting point for writing test is to code your requirements and the expected results before you implement it. This is called "Test Driven Development".
Another good practice is to write test code for all edge cases.
An advanced toolchain can script your app and inform you about UI bugs and even make some screen shots, what is useful for marketing like in the App Stores.
Playing an important role in development, because they are one of the main reasons for bugs. So always pay attention to edges case. Always ask yourself: "What is the worst case for the code". Sometimes division with zero, having not the access right to resources or the user may erratic input.
But the most important point is an attack like SQL injection. So handling the edge case plays an important role in the security of your code and your job and the well being of you and your organization.
Bugs are mistakes, everybody makes mistakes and so is part of the learning process, so they are like the "red ink" from the teacher. The most common cases are not fully checked edge cases or the misinterpretation of return codes. Fix them and learn from them, and make them only once. Most of the bugs are similar so using your favorite search engine often helps in fixing them. Here, you find the first bug in the computer history.
Some statistics are saying that around 1 bug per 1000 lines of written code. In libraries, there are fewer errors because of their massive usage. So, use libraries as much as possible.
In the Long Run
A higher education normally pays off. Your working career may be as long as 40 or 50 years, so NOT starting with the best education is a severe disadvantage. If you work early, you may regret it in 10 or 20 years when you don't have a fitting diploma for getting into the team lead or managment levels.
Normally, a university diploma means higher skills, more responsible work and so more pay. And it is to also best to build confidence when looking for a new challenge. Don't underestimate the managers wish for secure decision. If one has a diploma and the other has no one - who will get the job?
My simple words can only be a starting point for finding your own way of lifelong learning. I hope readers can take away some interesting thoughts and links for their next steps.
My advice is to do what you love because real engagement and hard work are keys for long term success. But it is also important to see the reality and the "market".
As an ancient Chinese saying goes, "even the biggest journey begins with the first step."