As an extremely jr Software Engineer, I'm trying to make sure I develop good habits. The challenge of using newlines when displaying output seems very simple (I'm sure to those who are seasoned), but how should they generally be used throughout a program that displays output in various places throughout code execution?
Example (assuming the language is java):
public class output
{
public static String usage = "usage: message";
public static void main(String[] args)
{
System.out.println("Starting program");
checkData();
System.out.println("Ending program");
}
public static void checkData()
{
System.out.println("Data checked");
# Assuming this method causes an exception
try
{
more code...
}
catch(IOException ioe)
{
System.out.println(ioe.getMessage());
System.out.pritnln(usage);
}
}
Clearly all of these messages would run together if everything were to be printed. So as a program grows, and seeing as though errors necessitate the need to output information as well, should newline characters be placed at the beginning, end, or wherever one decides throughout a program?
There is an advanced feature "aspect oriented programming". Spring framework has some built in stuff.
Try to search it, learn how to use it an add some anotation to the functions, it will handle the "entering to the function", "exiting the function" with a simple @MyLogStuff