Pages

Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

How to understand an existing complete (open source) code

Here are some of the good discussions on this topic. See at the end of the tips for more links.
  • If the code is written in a language you are not familiar with, then take a crash course on that particular language. If you are good at any programming language, you can easily learn most of the programming languages easily.
  • Use mind map to learn about the different modules used in main program, where each module is defined, different call functions in each modules, where they are called, where they are defined, what each modules, functions do, what are the external (used defined) functions, what are the user defined data types in this code etc.
  • You should also have a general idea about what the code does actually. What are the inputs, what are the outputs, what the code does, what are the algorithms used, etc.
  • If you think that some portion in the open source may be shortened (for more readability or more efficiency), you may try it and ask for pull request. This will improve the code as well as you have contributed to the code. In some cases, if you are not sure what to do, but you are sure that something can be done, use Code Review (for improvement of the working code). 
  • For a give module, understand what it does. Then, understand what are the inputs for that module. Then, test that module by giving different inputs.
  • Now, do that for functions. What are the functions used in a given module, what are the uses of those functions, what are arguments, what is calculated, what is returned, how it is calculated etc.
SE Software Engineering site has a good collection of questions and fantastic answers. Here are some of the links for answering the question:
Best practices for understanding/resurrecting old technical code?
What is the most effective way to add functionality to unfamiliar, structurally unsound code?
How do you dive into large code bases?
I've inherited 200K lines of spaghetti code — what now?


Using "tmux" for managing multiple screens

TMUX (tmux) is a fantastic tool for doing multitasks in terminal. For a programmer and researchers whose work involves coding, tmux is an essential tool.

In Ubuntu Linux, it can be installed by apt command.

To install from source code, download the package from this GitHub link.

Here are the important commands to use tmux.

tmux
tmux attach
ctrl + B   (the default prefix for tmux)
prefix + c   "Creates a window"
prefix + ,   To name/rename the panel
prefix + $  To name/rename the session
prefix + % vertical split
prefix + "   horizontal split
prefix + d   detach
prefix + d   ? to list all shortcuts
prefix + --> arrow : moves cursor to the right pane
prefix + <-- arrow : moves cursor to the left pane

To resize the panel size, prefix + Right /Lef/Down/Up arrow (i.e. --> or <--)
(Note that prefix followed by right/left arrow will move the cursor to the right/left pane)

It is also possible to restart entire tmux session after the restart. For this you need to use
tmux resurrect command. More on this later.

You can also see:
https://github.com/ssthurai/tmux-resurrect
https://github.com/ssthurai/tmux-continuum
For more commands, see this GitHub page on tmux.




You may be interested in these posts

Error in image file conversion: convert-im6.q16: not authorized `test.eps' @ error/constitute.c/WriteImage/1037.

This error is because of the vulnerability. This allows remote execution of code using image formats. So, some Linux distributions by defaul...