How configuration is effected into code flow? - configuration

Different kind of software offer different amount of configuration/customization. Routers are one of the most configurable software systems I know of. I want to know how routers handle configurations - how they alter the code flow based on the configuration?
One obvious way is to use if..else clauses provided by most of the language(let's assume we are using C)
So is there any other programming method(or paradigm?)
Data-driven programming paradigm may be viable one. Configuration can be thought of one of the input source and so can be used to alter the code flow.
What I need to know is, is there any papers and references that I can use to enrich my understanding. Not just routers any kind of software. If the question seems to vague, let me know I will add more details.

I don't know anything about configuration of routers, but your question states you are interested in configuration for any kind of software, so the following might be of interest to you.
I am the author of Config4*, which provides C++ and Java parsers for a particular configuration syntax. I suggest you do the following. Skim Chapters 2 and 3 of the "Config4* Getting Started Guide" (HTML, PDF) to get an overview of the configuration syntax and API. Then take your time reading the "Config4* Practical Usage Guide" (HTML, PDF), which discusses the "how to" for a variety of different ways to use configuration. Although the discussion in that manual makes use of the Config4* syntax and API, the principles could be used with another syntax, for example, XML. If you focus on the principles discussed in that manual, rather than the syntax, then I suspect you will start to develop some insight into how a router handles its configuration.

Related

How do I document my code to understand how it flows (works)?

I am writing a small game,and I now have 9 C# scripts that make it work. I have lost track of what exactly is happening and how. I want to know how things work from the moment the game starts. Whats happening and how, etc.
I am a beginner, and I have heard that writing down your program flow is called documenting it. How can I document? Do I have to write comments everywhere in my code to explain the flow of the program?
Putting extensive comments into your code is not a good approach. Basically you should try to make your code as self-explanatory as possible. You do this by carefully planning what belongs into a class or function and by using meaningful names for your classes, functions and variables. Comments are nothing but a last resort if additional explanation is really required.
In most cases you should also also have some documents in addition to the code that explain certain aspects of your software:
Requirements document - what is the purpose of the software, how is it used
Architecture and design specification - what are the modules and classes of the software and how do they interact. Often this document mainly consists of one or more diagrams (UML or something else).
Build manual - how to compile and link the software
Installation instructions
User manual
This list is neither complete nor is it mandatory. If, for example, the user interface of your software is simple and self-explaining, you probably won't need a user manual.
Sometimes diagrams make better documentation than text. There is a standard way of diagramming a control flow (whether it's of a program or a business process). They're called ... wait for it ... control-flow diagrams. But I don't think that's exactly what you're after.
There are also flow charts (often spelled as one word), which may be more suited to software than general control-flow diagrams. Flow charts can be useful for understanding an algorithm, but they generally don't give a good big-picture view.
With a complicated program, what might be more important to keep in mind is the data flow. For those we have ... can you guess? ... data-flow diagrams (DFDs).
DFDs can be drawn at varying levels of detail. You can have a high-level one that shows the major components of the system and how they fit together and low-level ones that show the nitty-gritty details for the portions of the system that require more detail.
DFDs can be used for a variety of analyses, including things like threat modeling. But I find them great for getting an overview of what's-what when I'm looking at a new project (or one I've forgotten about). You should be able to find some tutorials about DFDs online, and I think some drawing software (like Visio) have templates specifically for DFDs (and probably the other types of diagrams I've mentioned).
Some might consider DFDs a bit old-school and prefer more rigorous systems like UML (Unified Modeling Language), which is capable of expressing many more concepts and of having a very direct mapping between your "model" and your code. I've never learned enough UML to get much use out of it. The diagrams in many books on software patterns are expressed in UML.

Drafting ontology from API example and documention

While making good ontology is for sure big and mostly manual effort, it could be interesting to know if there are any techniques / tools, which automate making vendor-specific, intermediate ontologies for ETL process, given, say, rich-enough JSON examples combined with API documentation.
I am aware of Linked Data standards and techniques, but may be there is something in the form of library to make a draft RDFS+ ontology from API call responses?
For example, there are some libraries to guess JSON Schema (I have even written a primitive one myself), so the task does not seem to have problems in theory.
Please, do not consider this question as "software recommendation" one, because I doubt there is any software for this, but at least educated guess at direction I can take with this. I also believe, this is very important for semantic / linked data projects, and I wonder why I can't find any hints and need to ask for help from more experienced here.

Sphinx pages vs wiki pages

If you just want to create an HTML-documentation, what are the advantages of using Sphinx as a documentation api against using MediaWiki?
It really all depends on the workflow that you and, if applicable, people working with you, are used to. More than advantages it is a matter of taste and what you are used to. For me the perceived advantages of sphinx-doc are:
Easier editing of the files in an external editor
Version control of documentation using a VCS (svn, fossil or git)
I'm used to markdown syntax
But i think that for each of these points someone could argue an advantage for mediawiki, hence I think it is a matter of taste and preference.
However, if you are collaborating with non-technical people: mediawiki or fossil-wiki will be easier for them to add to the project / review pages and make corrections. By the same token if your documentation needs to be in sync with other documents (code or data) then sphinx-doc in the same version control system would have my preference.
I mention fossil-wiki because it offers a combination of both options and for some projects gives the best of both worlds. You can have wiki-pages that people can edit in the traditional sense (through an online front-end) and .wiki pages that are edited as if they are source and cannot be changed through the front end. Again, whether that makes sense to you depends on your use case and writing style and habits.

Choosing an opensource license for a library [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I thinking of a good opensource licence to choose for my project. I got a few requirements but I have a hard time choosing a license because a read some different things about some of them.
The project is a Java project that can calculate decompression schemes for scuba diving. I want this project to be opensource because a wrong decompression scheme can be lethal. Therefore feedback on the algorithms and source code is important for me. I don't make my own algorithms but I use various opensource algorithms that I implement in 1 Java library.
My requirements are:
I and other contributers to the project don't want to be responsible for wrong calculated decompression schemes due to bugs in the code, miss use of the code or any other way that resulted in wrong decompression schemes.
The library should be able to use on a website I plan to build without the need to publish the server side code of the website.
It's not allowed to make any profit of the library itself. Even not even the library is changed and republished. However I don't mind if people sell programs the make use of the library.
If people change the code than they should be forced to re publish the library with an opensource licence (Optional requirement).
I hope someone with a bit more knowledge of licenses can help me out.
Well, there are a couple of things I notice right off the bat here.
First off, you talk about needing to be able to do things with your own code. If you are the copyright holder, you can do pretty much anything you damn well please with your own code. The license is for other people, not for you.
Also, disclaiming any responsibility for what the code may do to other folks is pretty much boilerplate with any license.
That being said, I've found in my work I can get by with the use of only 3 different kinds of licenses, depending on my needs.
Full on GPL
Benifits:
Nobody can ever take any of the code propreitary (without coming to me for a relicense). They can still use it and charge people, but since they'd have to license the result GPL, that wouldn't be particularly practical. The reason is that any of their users could give away all the free copies they like.
The sources are avilable for anybody to contribute to, so I might not have to find and fix every damn bug and write every new feature myself.
Drawbacks:
None of the code is usable in a properitary app
I use this typically for stand-alone apps.
GPL with linking exceptions
This is basically what it says; GPL with an exception that meerly linking against (or #including) the code does not render the entire result GPL. Here's an example from the Classpath library.
Benifits:
Nobody can ever take the code itself proprietary.
The code can be used in a proprietary product without making the whole closed-source product open-source. Only the GPL-licensed stuff has to stay GPL.
Drawbacks:
The facility itself can never be expanded into a proprietary facility. Generally a plus in my book, but it does deter some people from using it.
I use this typically for helper facilities and API's .
Public Domain
This means anyone can do anything they like with this code, including making a tiny tweak, slapping their own copyright on it and calling it theirs.
Benifits:
Anybody can feel free to use it however they like.
Drawbacks:
No protection from the code getting "stolen" by a proprietary software seller.
Impossible to do in may jurisdictions (a permissive BSD I understand can be a good alternative there).
I use this when I'm publishing something incomplete that I really want someone else to take over, or when publishing something that is supposed to be a reference implementation for a standard library.
Now in a case like yours what I would do is either:
Use GPL with the linking exceptions for the library. That will allow everyone (including you) to use the library in a proprietary application, but the library itself will always stay Free.
Use GPL, and insist that contributions from others have their copyrights assigned back to you. This allows you full rights to make your own proprietary app using other people's contributions, and doesn't allow anyone else (including those contributors) that same right. Kinda cheesy in my book, and will probably discourage outside contributors. However, only the most successful Free Software projects get any outside contributors anyway. So it may not be that much of a loss.
It came to my attention recently that Bruce Perens (one of the founders of OSI) actually made a blog post a year earlier that made the exact same point. He picked two different licenses than I did for the latter two though. He picked LGPL for the intermediate license, which I think is a mistake on his part. However, he picked the Apache License 2.0 for the latter license, and I think he may have a point on that one. The benefit you get from using Apache over straight Public Domain is that you are better protected from patent lawsuits. That isn't something poor little me really has to worry about, but your company is a different matter entirely.
This impossible. You say you want an open source license that prohibits making money. However, one of the key requirements for being an open source license is not making any restrictions with respect to commercialization.
Ergo, a license like you describe it cannot possibly exist.
And here the standard answer: StackOverflow is a site for programming questions. We are programmers. Your question is a legal question. This means that all answers (including mine) will be, by definition, crap, since we don't know WTF we're talking about.
For legal questions, ask a lawyer.

I want to write a tool without usage entry barriers. Do I have to write it in C? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to write an open-source tool for use by developers. I want to eliminate entry barriers, so if they like the idea, they just get the tool and start playing with it.
In particular, I don't want an "Oh, should I also install 200Mb of ThatLanguage runtime libraries? Oh, so they don't build on my latest version of Linux?" entry barrier.
Should I write this tool in C, then? Or is Python, or Java, or whatever, already sufficiently widespread to not worry about this sort of things altogether (everyone already has them installed)?
Well, of course I know that they are freaking hugely widespread, but still - are there any major benefits to writing a super-lightweight zero-dependency tool, or am I being too much of a perfectionist?
Just write it first. If it is worth it people will use it.
Beyond that, (almost) everyone has Java, Python, and Ruby installed (especially devs). Some languages are still esoteric enough that it might not be worth it for 'that one app' (erlang, haskell, etc.).
Just write it though, that's the important part. From there it can be ported, rewritten, adopted, but none of that can happen if the tool isn't written first.
It won't help if people don't know C.
If you write your own DSL, you can have people use that API and not worry about which language you choose.
Write it in whatever common language you like. Everybody has installed .NET framework or JVM. The only difference between your C approach and Java or C# is, that you would link additional libraries directly to your program (opposed to standard libraries).
On the other hand I would hesitate to write it in some exotic language, for example smalltalk, because normal user does not know what is it squak or smalltalk itself and could be worried about installing the wierd thing :-).
I also think, that you should be concerned more about developers, because you write, you want it to be open source. I dont know anyone, who wants to write his own Swing, Spring or any other framework just to be independent of something. Also its (usually) much faster and easier to write it in JIT Language, than to code it in assembler...
I'm going to suggest what Reese suggested but take a slightly different approach: write it first, preferably in a language that allows you to quickly prototype and develop your program. Then, and this is the most important part, document the protocal you've developed.
I'm giving this advice because you mentioned that your "application" may later have bindings in lots of different languages and it is a client/server architecture. Well, two of the biggest applications in the world started out like this.
Bittorrent started out as Python code. This allowed very quick prototyping of the concept to get it working. The main thing that it had going for it was that the original code was well written and well documented. This later on allowed other people to port the protocol to other languages.
HTTP and HTML is an even bigger success story and started out with an even less popular language at the time it was written: objective-C. Even better than bittorrent, the protocol itself is very simple and very well documented. People didn't care that the original implementation was in a language that they've never seen before that uses square brackets in strange ways on a NeXT cube. The concept and execution was good and people quickly ported it to their favourite programming languages. Again, objective-C was chosen to aid in quick prototyping. Legend has it that the original implementation was written in just a couple of days.
I would say yes, you have to write it in C. If it were written in any language other than C (except perhaps C++ or Perl), I would definitely stop to consider whether the necessary build tools, runtime tools, and/or interpreter for that language would be available everywhere I might need the tool before getting myself dependent upon it. If the tool were meant for use in build scripts, I would consider it a complete show-stopper, since I can't expect anyone who wants to build my software to have random arbitrary language environments installed.
The reason I mentioned C++ and Perl as exceptions is that they're both largely portable in a formal sense. They have implementations that work without significant ties to the host implementation, and can be built not just on any current popular system but on any system that remotely adheres to standards. Python is quite the opposite, with strong dependencies on the underlying system's dynamic loader; I've been completely unable to get Python to work on various systems that only support static linking.
ocaml is another possible choice that has a very portable implementation, but it's not widely installed and people who aren't familiar with it tend to frown on it for no good reason.
If you write your program in C, then you will have the dependency of the platform (Windows != Linux != AIX, etc). If you are talking only about writing this tool for one OS, or rather THE OS (Linux;-), then I think that you can have a reasonable amount of confidence that your app will work on almost any system, especially if you use an Open Source language. If you want to run the app on Windows, I wouldn't count on any of those languages being installed on the host system. Your highest confidence across platforms will be with Java.
If possible you could use the lightest weight framework possible and put it online, where it can be viewed in a browser. What does your app do? Would it work as a web app?
I would suggest go for Delphi. If you want to make it portable, you can do it since most of the Delphi code is kylix compatible.