答:
The first issue you have to address is an emotional, irrational one. The IT industry is one in constant change and, although there are places for everything, refusing to improve or embrace change is a problem.

Why is your boss clinging to ANSI C? If that is the only language he or she knows then maybe it is time for a change but a rational argument may be insufficient. Will your boss feel undervalued or possibly fired if forced to work in an unfamiliar language? Emphasize the experience that he has and other benefits he brings.

If you do not solve this problem, all the rational arguments you can bring will be wasted. As a subordinate, you may not be the one that can have this discussion with him. Perhaps broach this subject to one of the other managers, if there are any.

Also consider it from your perspective. Why do you want to use C#? How much of this is the desire to use something new and cool? Be honest with yourself. If you recognise this, it will help you argue more effectively.

The second issue is one of risk and cost. Writing software is expensive and the choice of language is a major factor in that. Consider:

How long will it take to write in C# versus C? With easier object orientation and better garbage collection, C# may be easier. However, if the application uses lots of unmanaged API calls, C may be easier.

If you use C#, do you need to purchase additional tools? It sounds like you already use Visual Studio but do you need additional tools for localization, code review and analysis, debugging and so on?

How easy is it to maintain? If you find a bug, how quickly can it be fixed. C# can reduce this object orientation. Automatic garbage collection also avoids most memory leak and pointer issues.

How easy is it to support? If you have support staff, they may know how to read a crash dump but do they know how to use windbg with SOS? Do the target machines already have an appropriate version of the .Net framework installed?

Consider staffing. How many people know C versus C#? If either or both of you left the organization, how easy would it be to replace you? Are C developers cheaper or more expensive than C# developers?

I could go on but the point is to stop arguing on the technical merits of the languages alone. Technical merits are things only you and your boss understand. If you start talking business impact, you pull in a much wider group of people and make a far more convincing argument.

Maybe C is a better choice. C# is no automatically better for all situations. Maybe you do this project using C but do a C# proof of concept for the next one. Remember you can lose the battle but still win the war, too.


问:
Organisation of application development team wiki?
Looking for best-practice structure for setting up a wiki for developers?

I'll be managing a team that has not had the best track record for documentation, communication and knowledge-sharing.  I'd like to have a framework set up to make it easier for the team to get started in this area.

答:
First, it is important to choose a good Wiki. Choose one that:

Is well maintained and has good support.

Supports user authentication and has access control on documents or namespaces.

Tracks changes to documents and provides a history.

Allows E-mail notification of document changes.

Has a good editor, preferably WYSIWYG, and supports lists, tables and uploading images.

The biggest thing an development team Wiki needs is a "gardener": someone who is responsible for determining the layout and structure of documents in the Wiki. It does not have to be a full time role but the gardener should have strong English and an aptitude for explaining things well. The gardener should create standard templates for pages, naming conventions and determine what namespaces are required.

The gardener is not responsible for creating the content, more enforcing its structure. For example, if someone makes a change to a product, the gardener is not responsible for making the change to the Wiki. However, the gardener is responsible for making sure the change gets made and that it is done according to the guidelines (not just tacked on to a separate, unlinked page, for example). The gardener may review the changes or delegate that to someone else.

It is important to structure the Wiki to meet the needs of the audience rather than the needs of those creating content. For example, if you have a dedicated UI or security or localization team for software development, do not put their information in separate sections. Put them in the same section that the developers are looking at. Having everything together makes it much easier to find, ensures things do not get missed and identifies out of date content faster.

A Wiki needs a change in mindset. Many companies are used to information being forced upon them. A Wiki allows the consumers of the information to modify it. This should be strongly encouraged (and rewarded if need be). If inaccuracy is a concern, have reviewers configure the Wiki to E-mail them when modifications are made.

An development Wiki needs a strategy to handle versioning. If you have a set of documents for version 1.0, what happens when version 2.0 is released? Some of the documents for version 1.0 may still apply to 2.0 but some may be superseded. What if a change is made to a 1.0 document after the release of 2.0?

A Wiki needs some way of measuring success. How many people are using it? Did they find what they were looking for? You do not necessarily need a large, unsightly rating and comment box at the bottom of the page but a simple "E-mail a Human about this page" link may be helpful.

Lastly, the usage patterns of a Wiki will change over time. Remember to review any standards periodically to ensure they are still meeting the Wiki's needs.

ContentLicense: CC BY-SA 3.0


问:
What are some best practices for deleting from source control?
When is it okay to delete?

...destroy?

When should you never delete/destroy no matter how old (ie. health-management software?)

答:
What do you mean by "delete"? If you just want to remove files form the current HEAD (what the most recent version is called in most source control systems), go ahead. Most source control systems are designed to handle file deletions.

Indeed, once it is in the history, some source control systems make it very difficult to actually remove things form their history. If you have added a file that you want to remove, it is usually just easier to delete the file and do a commit with the file removed.

This is generally a good thing. You never know when you may want to get access to old code. The space requirements are usually not significant unless you have a huge number of large commits. As @nonnb says, you also may need it for audit and compliance purposes (e.g. ISO27001).

The only case when something should be removed from the revision history is when something sensitive has accidentally been committed, such as a private key, password, test data that contains real customer information or data that potentially breaches privacy regulations (PII).


问:
How can I convince my boss that ANSI C is inadequate for our new project?
A few months ago, we started developing an app to control an in-house developed test equipment and record a set of measurements. It should have a simple UI, and would likely require threads due to the continuous recording that must take place. This application will be used for a few years, and shall be maintained by a number of computer science students during this period.

Our boss graduated some 30 years ago (not to be taken as an offense; I have more than half that time on my back too) and has mandated that we develop this application in ANSI C. The rationale is that he is the only one that will be around the entire time, and therefore he must be able to understand what we are doing. He also ruled that we should use no abstract data types; he even gave us a list with the name of the global variables (sigh) he wants us to use.

I actually tried that approach for a while, but it was really slowing me down to make sure that all pointer operations were safe and all strings had the correct size. Additionally, the number of lines of code that actually related to the problem in hand was a only small fraction of our code base. After a few days, I scrapped the entire thing and started anew using C#. Our boss has already seen the program running and he likes the way it works, but he doesn't know that it's written in another language.

Next week the two of us will meet to go over the source code, so that he "will know how to maintain it". I am sort of scared, and I would like to hear from you guys what arguments I could use to support my decision.

Cowardly yours,

答:
Your boss would seem to be your customer in this case, and his primary requirement is that he be able to maintain the application when you move on.  This seems quite reasonable.

So, the choice is to do what he asks, or demonstrate that you can complete development AND teach him how to maintain a C# application within the time constraints and at a lower cost.  If you cannot do that, you are not meeting the requirements of the project.


答:
Just to be clear, I'm assuming that by 'destroyed' you mean permanent deletion of all versions of the file, versus just removing a file from the current branch.

IMO, valid source should never be destroyed. The only time anything needs to be deleted from a repository  (at least, in any ethical situation) is if the file shouldn't have been there in the first place, e.g. accidentally adding compiled artifacts like obj, bin, pch etc into the repository.

Rationale is:

Audits - finding out who changed what, when and why can be critical to getting to the bottom of an issue, and determining the impact of a bug on a customer base even after years  have passed (and 'proof' can be a job saver when it comes to the blame game, unfortunately)

Asset - remember that source is a company asset, which may need to be transferred if your company is sold, merged etc. Destroying old versions of source could be viewed in a dim light by bean counters, who won't be in a position to understand your argument that the code isn't relevant.

Size - Files in a VCS are usually compressed, so there isn't much incentive to delete to free up space etc.

A typical solution for removing source code from a project which is no longer wanted is to move it or archive it, although this is largely unnecessary in contemporary source control systems. (e.g. CVS has an attic)

Title: What are some best practices for deleting from source control?

Body:
When is it okay to delete?

...destroy?

When should you never delete/destroy no matter how old (ie. health-management software?)


答:
Notice that the "Please do it like this so I am sure I can maintain it" is actually a very good requirement - most programs spend much longer being maintained than being written and keeping a solution in a known technology is usually a good idea.

Just imagine if some new computer kid when asked for writing a C# application wrote it in Haskell in two days and said "Hey, it works and I'm gone, bye" leaving the maintenance on you.

Just imagine if some new computer kid when asked for writing an ANSI C application 15 years ago had written it in Visual Basic 6 in two days and left it.  Now you have to maintain it and Windows 7 starts complaining already when the installation media is inserted.

This might be a good opportunity to say - as Heinzi hinted in the comments - that "this is a quick prototype written in C# which happens to look very much like C - shall we make it production ready, or reimplement it in ANSI C like you asked", and then take the discussion now.  Having actual source to see, is much better than "Hey, shouldn't we write our next application in Haskell because its faster".

In other words - you now have the opportunity to demonstrate that a new platform could be considered.  Bring up that you wrote a prototype before the code review - this will help removing the impression that you are trying to sneak C# in under the radar.  I would suggest that you also demonstrate that all existing code written in ANSI C can be used from within C#.  Personally I believe you will be told that the target remains ANSI C to stay in a single platform.

Title: How can I convince my boss that ANSI C is inadequate for our new project?

Body:
A few months ago, we started developing an app to control an in-house developed test equipment and record a set of measurements. It should have a simple UI, and would likely require threads due to the continuous recording that must take place. This application will be used for a few years, and shall be maintained by a number of computer science students during this period.

Our boss graduated some 30 years ago (not to be taken as an offense; I have more than half that time on my back too) and has mandated that we develop this application in ANSI C. The rationale is that he is the only one that will be around the entire time, and therefore he must be able to understand what we are doing. He also ruled that we should use no abstract data types; he even gave us a list with the name of the global variables (sigh) he wants us to use.

I actually tried that approach for a while, but it was really slowing me down to make sure that all pointer operations were safe and all strings had the correct size. Additionally, the number of lines of code that actually related to the problem in hand was a only small fraction of our code base. After a few days, I scrapped the entire thing and started anew using C#. Our boss has already seen the program running and he likes the way it works, but he doesn't know that it's written in another language.

Next week the two of us will meet to go over the source code, so that he "will know how to maintain it". I am sort of scared, and I would like to hear from you guys what arguments I could use to support my decision.

Cowardly yours,


问:
Programmaticaly finding the Landau notation (Big O or Theta notation) of an algorithm?
I'm used to search for the Landau (Big O, Theta...) notation of my algorithms by hand to make sure they are as optimized as they can be, but when the functions are getting really big and complex, it's taking way too much time to do it by hand. it's also prone to human errors.

I spent some time on Codility (coding/algo exercises), and noticed they will give you the Landau notation for your submitted solution (both in Time and Memory usage).

I was wondering how they do that...
How would you do it?

Is there another way besides Lexical Analysis or parsing of the code?

This question concerns mainly PHP and or JavaScript, but I'm opened to any language and theory.

答:
I was wondering how they do that... How would you do it?

I imagine that they are actually estimating the Big O measures ... by running the program for different problem sizes, measuring time and space usage, and fitting curves to the results.

The problem with this approach is that it can get it wrong if the cost functions change shape as N gets large; e.g. 1000 N + N^1.5.

Is there another way besides Lexical Analysis or parsing of the code?

Lexical analysis and parsing are not sufficient.  You also need to do some reasoning about the behaviour of the algorithm.  And doing that automatically for a previously unknown algorithm is hard.


问:
C++ compiler structures such as Virtual method Table etc
I am aware of the C++ Virtual Table which allows dynamic dispatch for doing things at runtime (although if I am honest I am not completely sure of the full list of things it achieves).

I am wondering what other "low level" aspects of C++ are there, which one doesnt usually come across when learning the C++ language?

Things like:

-How is multithreading and locking on objects performed?

-Overloading/overwriting functions

-Generics

Are there other "structures", similar to the vtable, which assist with these types of things on a lower level?

(and if anyone can help with what the VTable actually does it would be most appreciated!)

答:
Virtual Table

I would guess that the most official description of virtual tables would be found in chapter 10 of The Annotated C++ Reference Manual (sometimes called ARM) by Margaret Ellis and Bjarne Stroustrup.  My copy is copyright 1990, not sure if that is the latest edition.

There are probably simpler, more graphic descriptions like

http://www.learncpp.com/cpp-tutorial/125-the-virtual-table/

or right here on Stack Exchange:

https://stackoverflow.com/questions/2173493/virtual-table-c

How is multithreading and locking on objects

I think this is not part of the original language.

p-threads (POSIX Threads) are a typical way to augment the language with a library and are supported on UNIX, Linux, and other operating systems including, surprisingly enough, even Windows.

Another library that supports threads is Boost.  I read somewhere than some of the Boost threading support was adopted by the C++ standards committee and appears in C++11.

C++11 supports threads in an update to the standard library.  There is also a notion of thread local storage that is described briefly from the same reference.

Overloading/overwriting functions

Chapter 13 of the ARM discusses this topic.

Generics

In C++ this would be templates.

Check chapter 14 of the ARM.


答:
Maybe another argument: It's probably very hard to find computer science students who have enough experience to write C code without making mistakes. ANSI C is not the first thing people learn today.

Now all computer science students will kill me.


答:
How would I do it? The way I solve almost any problem I don't want to sit down and solve. I simulate.

For many problems, it may be sufficient to run your algorithm many times using a variety of sizes, and then fit a regression curve to those results. That would quickly identify some particular "fixed" overhead costs of your algorithm (the intercept of the curve) and how it scales as your problem size increases.

Some tinkering will be needed to capture particularly complicated solutions, but especially if you're just looking for a ball-park estimate, you should be able to obtain it that way, and see how your estimate differs from your actual results and decide if it's an acceptable approximation.

The greatest weakness in my mind with this method is that if your algorithm scales really poorly, that initial "run it a whole bunch of times" step is going to get ugly. But frankly, it thats the case, that alone should be an indicator that you might want to step back and reconsider things.

Title: Programmaticaly finding the Landau notation (Big O or Theta notation) of an algorithm?

Body:
I'm used to search for the Landau (Big O, Theta...) notation of my algorithms by hand to make sure they are as optimized as they can be, but when the functions are getting really big and complex, it's taking way too much time to do it by hand. it's also prone to human errors.

I spent some time on Codility (coding/algo exercises), and noticed they will give you the Landau notation for your submitted solution (both in Time and Memory usage).

I was wondering how they do that...
How would you do it?

Is there another way besides Lexical Analysis or parsing of the code?

This question concerns mainly PHP and or JavaScript, but I'm opened to any language and theory.


问:
How to teach Exception Handling for New Programmers?
How do you go about teaching Exception Handling to Programmers. All other things are taught easily - Data Structures, ASP.NET, WinForms, WPF, WCF - you name it, everything can be taught easily.

With Exception Handling, teaching them try-catch-finally is just the syntactic nature of Exception Handling.

What should be taught however is - What part of your code do you put in the try block? What do you do in the catch block?

Let me illustrate it with an example.

You are working on a Windows Forms Project (a small utility) and you have designed it as below with 3 different projects.

UILayer

BusinessLayer

DataLayer

If an Exception (let us say of loading an XDocument throws an exception) is raised at DataLayer (the UILayer calls BusinessLayer which in turns calls the DataLayer), do you just do the following

```<code>//In DataLayer
try {
    XDocument xd_XmlDocument = XDocument.Load("systems.xml");
}
catch(Exception ex)
{
    throw ex;
}
</code>```

which gets thrown again in the BusinessLayer and which is caught in UILayer where I write it to the log file?

Is this how you go about Exception Handling?

答:
Lets do a role play. (this is not a joke post)

You should do a workshop where you act out the call chain.
Each person is an object. You'll need some newbies and some people who understand the "game" helps.

Use a really simple issue like file IO.
gui->model->file_io

The person being the file reader needs to tell the next one up....

First do it with return codes. ( use post-it notes ?)

if the interactions are just "what the code says" pretty soon you can get people to realize that exceptions are exceptional.

for return codes, pass a post-it note.

for exceptions, throw your hands in the air and say what the problem is.

then get them to do "catch x, throw x" and see ho much worse the diagnosis is what the GUI just gets "the model had an exception".

I think this will work to train the people you have because people understand interactions with other people pretty well.

ContentLicense: CC BY-SA 2.5


问:
What is a zombie process or thread?
What is a zombie process or thread, and what creates them?  Do I just kill them, or can I do something to get diagnostics about how they died?</p>

答:
A zombie thread is a thread that have terminated its execution but didn't terminated cleanly. It deallocates the resources used by the thread but keeps an entry in the thread/process table.

Theoretically, the zombie thread exits from this status by executing a _join (POSIX). It means that when your main is finished, the zombie process would be killed with the program.

Title: What is a zombie process or thread?


答:
What is a zombie process or thread, and what creates them?

A zombie process is a dead processes.

The OS is just keeping information around so the parent can check the exit code of the processes at some later point as such the OS keeps information about them and thus they turn up when looking at processes.

Do I just kill them,

No. They are already dead.

The OS will clean up when the parent dies or gets the status code from the OS.

or can I do something to get diagnostics about how they died?

No. The parent can but not the shell.

Title: What is a zombie process or thread?

Body: What is a zombie process or thread, and what creates them?  Do I just kill them, or can I do something to get diagnostics about how they died?</p>


答:
Don't focus too much on getting a perfect structure up front, better let it grow organically. It's the communication culture and process that matter.

Below are some tips to maintain team wiki.

fundamentals

value feedback

Ask for, collect and record any feedback you can get - mail, wiki page comments (most convenient btw), messenger, conversation.

recording feedback

Q: what if I currently don't have time to properly process the information?

A: save it at the page as-is - for future processing and hide it from regular readers like as follows: {excerpt:hidden=true}information to be processed later{excerpt}

processing feedback

try to do it as fast as possible. Details and context that look obvious to you or submitter right now, can be forgotten a day or week or month later

consider alternative solutions to problem(s) pointed in feedback. Example:

(feedback) hey the information I need is mixed with useless one

(wrong action) OK I remove stuff you don't need

(right action) OK I will split the information
to one of your interest and the rest that
might be of interest for someone else

handling suggestions implying long term work

Q: what if suggestion is like say "collect and rearrange all relevant data documented at thousand other pages"?

A: add a TODO-s section to your page (if it's not there yet) and record the suggestion in this section. Later, you can use it also to track your progress

      update DD.MM.YYYY: 475 pages of 1000 are processed

handling suggestions that look wrong to you

Side note it never hurts to ask the suggestion submitter for clarification. Though, you'd better do your part of job first:

check the page history, taking into account review date. There is always a chance that submitter points to the issue from older version that is already corrected

look closer at the page/section referred to and ask yourself, what could cause him/her to think that way?

(after a little training with trick like above) you'll find out that in most if not all cases, there is a distinct area for improvement there.

Imagine for example, user complaining about missing information which is actually present somewhere in the page. Despite looking wrong on the surface, such a complaint often indicates a serious problem at the page: namely that some important information is hard to find. Giving it a visibility it deserves will improve the page.

better fast than perfect

Rely on review and feedback. If something really needs correction, time will sort it out for you

this also applies to self-review. Record the draft of what you want to put to page and review it yourself an hour (or day, or week) later - this trick can do wonders

don't waste time on making things perfect at the first try - it's impossible

record the information as soon as it looks barely acceptable and ask those interested to review it

be bold

Be bold when updating pages: fix problems, correct grammar, add facts, make sure wording is accurate, etc.

Above is based in Wikipedia principle and is best explained, well, at Wikipedia

...but please be careful - take care of the common good and not edit recklessly: a clarification to principle above,

also explained at Wikipedia

advanced

be thankful

People giving feedback are a valuable asset, be thankful to them. These people took their time and effort to not only read your page, but also to provide their feedback. Vast majority of your users won't be that generous to you. Those sharing their thoughts are "the cream" of your audience, be thankful for their contribution.

explain TLA-s

If you can't figure what's TLA? - you've got the point

use links for that if possible: TLA

record answers to questions

Respect others time - record answers

It might take you one second to answer to question, but think about the guy who asked it instead? (S)he took time to read your page, to try to find the answer, to contact you and wait for your answer. If you record the answer at the page, you'll save all that time for next guy having this question.

Record answers to your own questions. What is unclear to you, might be unclear to the next reader.

use question marks

When in doubt, use question marks

Confluence syntax as an example: (?)
Example: <this info> needs checking

this way, any reader can clearly see what sort of info you need; chances are high that someone can help you clarify things

links are your friends

DRY - don't try to copy information when you can provide the link instead

learn to summarize when needed

some link
- hey what's this?

some link - Wikipedia, the free encyclopedia that anyone can edit.

visuals matter

When you have time, self-review your page asking yourself if it is easy for the reader to get the point(s) you are willing to make

It can be quite difficult to find substance in an unstructured stream of consciousness

...I gave him all the pleasure I could leading him on till he asked me to say yes and I wouldnt answer first only looked out over the sea and the sky I was thinking of so many things he didnt know of Mulvey and Mr Stanhope and Hester and father and old captain Groves and the sailors playing all birds fly and I say stoop and washing up dishes they called it on the pier and the sentry in front of the governors house with the thing round his white helmet poor devil half roasted and the Spanish girls laughing in their shawls and their tall combs and the auctions in the morning the Greeks and the jews and the Arabs and the devil knows who else from all the ends of Europe and Duke street and the fowl market all clucking outside Larby Sharons and the poor donkeys slipping half asleep and the vague fellows in the cloaks asleep in the shade on the steps and the big wheels of the carts of the bulls and the old castle thousands of years old yes and those handsome Moors all in white and turbans like kings asking you to sit down in their little bit of a shop and Ronda with the old windows of the posadas 2 glancing eyes a lattice hid for her lover to kiss the iron and the wineshops half open at night and the castanets and the night we missed the boat at Algeciras the watchman going about serene with his lamp and O that awful deepdown torrent O and the sea the sea crimson sometimes like fire and the glorious sunsets and the figtrees in the Alameda gardens yes and all the queer little streets and the pink and blue and yellow houses and the rosegardens and the jessamine and geraniums and cactuses and Gibraltar as a girl where I was a Flower of the mountain yes when I put the rose in my hair like the Andalusian girls used or shall I wear a red yes and how he kissed me under the Moorish wall and I thought well as well him as another and then I asked him with my eyes to ask again yes and then he asked me would I yes to say yes my mountain flower and first I put my arms around him yes and drew him down to me so he could feel my breasts all perfume yes and his heart was going like mad and yes I said yes I will Yes.

relax and have fun

Keep in mind that typically readers of your page are not required to be dead serious.

when you feel it's appropriate to have fun - have it

fight link rot

You are willing to move some page or resource?

Fine, just think about the guys keeping links to it somewhere in their bookmarks, emails archives, documents etc etc

When you (re)move the page or a document, keep a placeholder where it previously was located, to help visitors understand what happened to it and where to go instead

<this page> has been moved to <that page>

<this document> has been removed because of <the reason>

References for further reading

Wikipedia policies and guidelines

Confluence notation guide

Wiki patterns

Title: Organisation of application development team wiki?

Body:
Looking for best-practice structure for setting up a wiki for developers?

I'll be managing a team that has not had the best track record for documentation, communication and knowledge-sharing.  I'd like to have a framework set up to make it easier for the team to get started in this area.


答:
They can't without analysing the code.

Below examples with artificial "inflation / deflation" of complexity proves that simply measuring program runtime is not sufficient to reliably estimate Big-O

```<code>void lets_trick_runtime(int n) {
   if (n == 10 || n == 25 || n == 118) {
      // unfair speed-up
      do_precalculated_solution_in_constant_time(n);
      return;
   }
   if (n == 11 || n == 26 || n == 119) {
      // unfair slow-down
      do_some_fake_processing_in_n_cube_time(n);
      return;
   }
   // fair solution
   do_general_solution_in_quadratic_time(n);
}
</code>```

Runtime estimation for above would be succeptible to giving fake estimates - constant time for values of n where there is a pre-calculated solution and cubic time for values where unfair slow-down kicks in - instead of "fair" quadratic time.

Body:
They can't without analysing the code.

Below examples with artificial "inflation / deflation" of complexity proves that simply measuring program runtime is not sufficient to reliably estimate Big-O

void lets_trick_runtime(int n) {
   if (n == 10 || n == 25 || n == 118) {
      // unfair speed-up
      do_precalculated_solution_in_constant_time(n);
      return;
   }
   if (n == 11 || n == 26 || n == 119) {
      // unfair slow-down
      do_some_fake_processing_in_n_cube_time(n);
      return;
   }
   // fair solution
   do_general_solution_in_quadratic_time(n);
}

Runtime estimation for above would be succeptible to giving fake estimates - constant time for values of n where there is a pre-calculated solution and cubic time for values where unfair slow-down kicks in - instead of "fair" quadratic time.


答:
Well, the first thing to do is to go to your boss and fess up.  You've disregarded his clear request, and worse have been doing so for months.  I don't know how much time you've got into this, but assuming that it's most of the time allocated for getting the project done, you have to face up to the fact that you may soon be looking for a new job.

The sooner you deal with this the better.

Secondly, I don't think you can convince him that ANSI C is inadequate, what you need to do is convince him of several other things (1) that c# is adequate, (2) he can easily learn to maintain c#, (3) that you were inadquate to writing it in C. Assuming that you still have a job and a part to play with this project, I would concentrate on 2, emphasising the similarities between c and c#.

Quotes in response to comments...

A few months ago, we started developing an app [...]
  After a few days, I scrapped the entire thing and started anew using C#


问:
It is inconsiderate to place editor settings inside code files?
I know this is kind of a subjective question, but I'm curious if there's any good reason to place (or not place) editor settings inside code files. I'm thinking in vi modelines, but it is possible that this applies to other editors.

In short, a vi modeline is a line inside a file that tells vi how to behave (indent with spaces or tabs, set tabwidth to X, autoindent by default or not, ...) that is placed inside a comment, so it won't affect the program/compiler when running. In a .c file it could be similar to

```<code>// vim: noai:ts=4:sw=4
</code>```

On one hand, I think this shouldn't be inside the file, as it is an editor setting and so belongs to an editor configuration file or property. On the other hand, for projects involving developers outside one company (that are not imposed an editor/settings) or collaborators on github/bitbucket/... it is an easy way to avoid breaking the code style (tabs vs spaces for example), but only for the ones that use that editor though.

I cannot see any powerful enough reason to decide for or against this practice, so I am in doubt of what to do.

答: This is very useful in cases such as where your standard practice is spaces isntead of tabs, but then one type of file (say a Makefile) requires tabs. I wouldn't use it to force my personal editor preferences on other people though. As long as your code doesn't require weird settings, which it shouldn't, then other people can look after themselves when it comes to their editor settings.</p>


问:
Is There a Real Advantage to Generic Repository?
Was reading through some articles on the advantages of creating Generic Repositories for a new app (example). The idea seems nice because it lets me use the same repository to do several things for several different entity types at once:

```<code>IRepository repo = new EfRepository(); // Would normally pass through IOC into constructor
var c1 = new Country() { Name = "United States", CountryCode = "US" };
var c2 = new Country() { Name = "Canada", CountryCode = "CA" };
var c3 = new Country() { Name = "Mexico", CountryCode = "MX" };
var p1 = new Province() { Country = c1, Name = "Alabama", Abbreviation = "AL" };
var p2 = new Province() { Country = c1, Name = "Alaska", Abbreviation = "AK" };
var p3 = new Province() { Country = c2, Name = "Alberta", Abbreviation = "AB" };
repo.Add<Country>(c1);
repo.Add<Country>(c2);
repo.Add<Country>(c3);
repo.Add<Province>(p1);
repo.Add<Province>(p2);
repo.Add<Province>(p3);
repo.Save();
</code>```

However, the rest of the implementation of the Repository has a heavy reliance on Linq:

```<code>IQueryable<T> Query();
IList<T> Find(Expression<Func<T,bool>> predicate);
T Get(Expression<Func<T,bool>> predicate);
T First(Expression<Func<T,bool>> predicate);
//... and so on
</code>```

This repository pattern worked fantastic for Entity Framework, and pretty much offered a 1 to 1 mapping of the methods available on DbContext/DbSet. But given the slow uptake of Linq on other data access technologies outside of Entity Framework, what advantage does this provide over working directly with the DbContext?

I attempted to write a PetaPoco version of the Repository, but PetaPoco doesn't support Linq Expressions, which makes creating a generic IRepository interface pretty much useless unless you only use it for the basic GetAll, GetById, Add, Update, Delete, and Save methods and utilize it as a base class. Then you have to create specific repositories with specialized methods to handle all the "where" clauses that I could previously pass in as a predicate.

Is the Generic Repository pattern useful for anything outside of Entity Framework? If not, why would someone use it at all instead of working directly with Entity Framework?

Original link doesn't reflect the pattern I was using in my sample code. Here is an (updated link).

答:
Generic repository is even useless (and IMHO also bad) for Entity Framework. It doesn't bring any additional value to what is already provided by IDbSet<T> (which is btw. generic repository).

As you have already found the argument that generic repository can be replaced by implementation for other data access technology is pretty weak because it can demand writing your own Linq provider.

The second common argument about simplified unit testing is also wrong because mocking repository / set with in-memory data storage replaces Linq provider with another one which has different capabilities. Linq-to-entities provider supports only subset of Linq features - it even doesn't support all methods available on IQueryable<T> interface. Sharing expression trees between data access layer and business logic layers prevents any faking of data access layer - query logic must be separated.

If you want to have strong "generic" abstraction you must involve other patterns as well. In this case you need to use abstract query language which can be translated by repository to specific query language supported by used data access layer. This is handled by Specification pattern. Linq on IQueryable is specification (but the translation requires provider - or some custom visitor translating expression tree into query) but you can define your own simplified version and use it. For example NHibernate uses Criteria API. Still the simplest way is using specific repository with specific methods. This way is the simplest to implement, simplest to test and simplest to fake in unit tests because the query logic is completely hidden and separated behind the abstraction.

OwnerDisplayName: Sam

ContentLicense: CC BY-SA 4.0


问:
java application architecture
We have to write an administration panel for many customers. But we want to have just one administration panel, and use it in various projects.

This admin panel will have basic components such as access control logic, maker-checker system in changes, user logging and etc.

It will also have reporting for the customer, logs of transaction of the customer (which can vary according to the industry such as mobile banking, banking, ticket sales). These components may have to be modified according to the business.

So we are thinking about the architecture here, Is it OK to use jars of every basic components, and bring them together on a glue application? Or should we build each component as WARs and make interfaces between them?

If there are any more ideas, it will be appreciated.

答:
It sounds like you're looking for a plugin architecture here. a JSR-330 Dependency injection approach (e.g. That Maven and Hudson use) might be a good way forward here. Actually since you're talking web app, you'll want to look at the Java EE CDI std.

I don't see a need to have them as separate WAR files communicating over RESTFul or SOAP based services, it should be a small enough app that one WAR makes sense.

Title: java application architecture


问:
Why is the concept of lazy evaluation useful?
It seems lazy evaluation of expressions can cause a programmer to lose control over the order in which their code is executed. I am having trouble understanding why this would be acceptable or desired by a programmer.

How can this paradigm be used to build predictable software that works as intended, when we have no guarantee when and where an expression will be evaluated?

答:
with lazy evaluation you do not lose control about code execution, it is still absolutely deterministic. It is hard to get used with it, though.

lazy evaluation is useful because it is a way of reduction of lambda-term that will terminate in some cases, where eager evaluation will fail, but not vise versa. This includes
1) when you need to link to computation result before you actually execute computation, for example, when you constructs cyclic graph structure, but want to do it in functional style
2) when you define infinite data structure, but function this structure feed to use only part of datastructure.


答:
I never thought about it, but I'd say:

Things which should always be the same for this file, it's good (but unusual) to specify within the file. Eg. most projects should have a guidelines that files always use spaces, or always use tabs, so if that's specified in the file it can only help.

Anything that's a personal preference for developers should NOT be in a shared file. It doesn't matter how much developer A likes auto-indent, she/he doesn't know whether other people don't like it or have a good reason not to use it. But don't make a big stink, just remove it and/or ask developer A if it's ok -- they may well not have noticed.

It's unlikely, but if developer A genuinely wants different settings for different files and developer B doesn't they need to talk to each other and come to a compromise that lets them both get want they want. They may not have realised there's a problem.

Title: It is inconsiderate to place editor settings inside code files?

Body:
I know this is kind of a subjective question, but I'm curious if there's any good reason to place (or not place) editor settings inside code files. I'm thinking in vi modelines, but it is possible that this applies to other editors.

In short, a vi modeline is a line inside a file that tells vi how to behave (indent with spaces or tabs, set tabwidth to X, autoindent by default or not, ...) that is placed inside a comment, so it won't affect the program/compiler when running. In a .c file it could be similar to

```<code>// vim: noai:ts=4:sw=4
</code>```

On one hand, I think this shouldn't be inside the file, as it is an editor setting and so belongs to an editor configuration file or property. On the other hand, for projects involving developers outside one company (that are not imposed an editor/settings) or collaborators on github/bitbucket/... it is an easy way to avoid breaking the code style (tabs vs spaces for example), but only for the ones that use that editor though.

I cannot see any powerful enough reason to decide for or against this practice, so I am in doubt of what to do.


答:
When the thread/process is killed, but there is still a record in the corresponding table about it, it becomes a zombie.

This can happen when, for example, a parent process creates a child process, but terminates before the child. When the child process terminates, it tells it's parent about terminating. Afterwards the record of the child process is removed from the corresponding table. But it's parent has already terminated, so the record still remains in the table.

There is no way to get rid of zombies but reboot the

Title: What is a zombie process or thread?


问:
Review before or after code commit, which is better?
Traditionally we performed code review before commit, I had an argument with my colleague today, who preferred code review after commit.

First, here's some background,

We have some experienced developers and we also have new hires with almost zero programming experience.

We'd like to perform fast and short iterations to release our product.

All team members are located at the same site.

The advantages of code review before commit I've learned:

Mentor new hires

Try to prevent errors, failures, bad designs early in the development cycle

Learn from others

Knowledge backup if someone quits

But I've also had some bad experiences:

Low efficiency, some changes may be reviewed over days

Hard to balance speed and quality, especially for newbies

One team member felt distrust

As to post-commit review, I know little about this, but the thing I'm most worried about is the risk of losing control due to lack of review.
Any opinions?

UPDATE:

We're using Perforce for VCS

We code and commit in the same branches (trunk or bug fixing branches)

To improve efficiency, we've tried to split code into small changes. We've also tried some live dialog review, but not everyone followed the rule. This is another problem though.

答:
I've recently started doing pre-commit reviews in a project I'm in and I must say I'm pleasantly surprised about how unproblematic it is.

The biggest drawback of post-commit reviews that I see is that it's often a single-person-only afair: Someone reviews the code for correctness, but the author is not usually involved unless there's a serious mistake. Small problems, suggestions or hints don't usually reach the author at all.

This also changes the perceived result of the code reviews: it's seen as something that only produces additional work, as opposed to something where everyone (the reviewer and the author of the code) can learn new things every time.


答:
With peer review there is a minimal risk of losing control. All the time two people have knowledge about the same code. They have to switch occasionally, so they have to be attentive all the time to keep track of the code.

It makes sense to have a skillful developer and a newbie working together. At first glance this seems to be inefficient, but it isn't. In fact, there are fewer bugs, and it takes less time to fix those. Besides, the newbies will learn much faster.

What comes to preventing bad design, this should be done before coding. If there is any considerable change/improvement/new piece of design, it should be reviewed before coding starts. When design is completely developed, there is not much left to do. Reviewing the code will be easier and will take less time.

I agree that it is not essential to review code before committing only if the code is produced by an experienced developer, who have already proved their skills. But if there's a newbie, code should be reviewed before committing: the reviewer should sit next to the developer and explain every change or improvement made by them.

Title: Review before or after code commit, which is better?

Body:
Traditionally we performed code review before commit, I had an argument with my colleague today, who preferred code review after commit.

First, here's some background,

We have some experienced developers and we also have new hires with almost zero programming experience.

We'd like to perform fast and short iterations to release our product.

All team members are located at the same site.

The advantages of code review before commit I've learned:

Mentor new hires

Try to prevent errors, failures, bad designs early in the development cycle

Learn from others

Knowledge backup if someone quits

But I've also had some bad experiences:

Low efficiency, some changes may be reviewed over days

Hard to balance speed and quality, especially for newbies

One team member felt distrust

As to post-commit review, I know little about this, but the thing I'm most worried about is the risk of losing control due to lack of review.
Any opinions?

UPDATE:

We're using Perforce for VCS

We code and commit in the same branches (trunk or bug fixing branches)

To improve efficiency, we've tried to split code into small changes. We've also tried some live dialog review, but not everyone followed the rule. This is another problem though.


答:
Like Simon Whitehead mentions in his comment, it depends on your branching strategy.

If the developers have their own private branch for development (which I'd recommend in most situations anyway), I'd perform the code review prior to merging with the trunk or main repository. This will allow developers to have the freedom to check in as frequently as they want during their development/testing cycle, but any time code goes into the branch that contains the delivered code, it gets reviewed.

Generally, your bad experiences with code reviews sound more like a problem with the review process that have solutions. By reviewing code in smaller, individual chunks, you can make sure it doesn't take too long. A good number is that 150 lines of code can be reviewed in an hour, but the rate will be slower for people unfamiliar with the programming language, the system under development, or the criticality of the system (a safety critical requires more time) - this information might be useful to improve efficiency and decide who participates in code reviews.


答:
Pre-commit code reviews seem so natural, it never occurred to me that reviews could deliberately be done after committing. From a continuous integration perspective, you want to commit your code once it is finished, not in a working-but-possibly-poorly-written state, right ?

Maybe it's because the way we've always done it in my teams is live dialog initiated by the original developer, not asynchronous, control-driven, document-based reviews though.


答:
A zombie process is a process that has both terminated its execution and has been removed from the list of scheduled processes, but has not yet been deleted.  Depending upon the OS, tt might or might not still have various resources assigned to it, and may be queried, but it will not run.

Some OS'es (by design) are not allowed to dynamically create or delete resources beyond a certain event point (VxWorks Cert for example).  Such systems often work around this limitation by using pre-allocated pools of resources from which they retrieve, return and reuse items.  However, when a process on such a system terminates, it can not be deleted and will instead become zombified (terminated and removed from the scheduling list).

Hope this helps.

Title: What is a zombie process or thread?


答:
It depends on your team make up. For a relatively experienced team that is good about small, frequent commits then post-commit review just to get a second pair of eyes on the code is fine. For larger, more complex commits and/or for less experienced developers then pre-commit reviews to fix problems before they get in seems more prudent.

Along those lines, having a good CI process and/or gated check-ins lessens the need for reviews before commit (and arguably post commit for many of them).


问:
How to use the unit of work and repository patterns in a service oriented enviroment
I've created an application framework using the unit of work and repository patterns for it's data layer. Data consumer layers such as presentation depend on the data layer design. For example a CRUD abstract form has a dependency to a repository (IRepository).

This architecture works like a charm in client/server environments (Ex. a WPF application and a SQL Server). But I'm looking for a good pattern to change or reuse this architecture for a service oriented environment.

Of course I have some ideas:

Idea 1: The "Adapter" design pattern

Keep the current architecture and create a new unit of work and repository implementation which can work with a service instead of the ORM. Data layer consumers are loosely coupled to the data layer so it's possible but the problem is about the unit of work; I have to create a context which tracks the objects state at the client side and sends the changes to the server side on calling the "Commit" (Something that I think the RIA has done for Silverlight). Here the diagram:

```<code>----------- CLIENT----------- | ------------------ SERVER ----------------------

[ UI ] -> [ UoW/Repository ] ---> [ Web Services ] -> [ UoW/Repository ] -> [DB]
</code>```

Idea 2: Add another layer

Add another layer (let say "local services" or "data provider"), then put it between the data layer (unit of work and repository) and the data consumer layers (like UI). Then I have to rewrite the consumer classes (CRUD and other classes which are dependent to IRepository) to depend on another interface.

And the diagram:

```<code>----------------- CLIENT ------------------ | ------------------- SERVER ---------------------

[ UI ] -> [ Local Services/Data Provider ] ---> [ Web Services ] -> [ UoW/Repository ] -> [DB]
</code>```

Please note that I have the local services layer on the current architecture but it doesn't expose the data layer functionality. In another word the UI layer can communicate with both of the data and local services layers whereas the local services layer also uses the data layer.

```<code>|    |      |                 |      |      |
|    | ---> |  Local Services | ---> |      |
| UI |      |                 |      | Data |
|    |                               |      |
|    | ----------------------------> |      |
</code>```

答:
I'd argue that your second approach is on track. To me, exposing the repositories/uow directly to the client is brittle. Your client becomes dependent on the mechanics of the domain layer (and this gets exacerbated as you add different clients to the server tier).

There is another pattern, the Application Service Layer that provides a shell around your domain model and acts as an intermediary between the client and the domain. It allows you to create operations that a custom-fit for the client, and for the details of the domain to still be fluid without impacting the client.


答:
Most repositories today support a two-phase commit or a shelveset (private branch, pull request, patch submission or whatever you want to call it), that will allow you to inspect/review work before pulling it into the main line. I would say that leveraging these tools would allow you to always do pre-commit reviews.

Also, you might consider pair coding (senior pairs with junior) as another way of providing a built-in code review. Consider it as a quality inspection on the assembly line instead of after the car has rolled off.


问:
Should curly braces appear on their own line?
Should curly braces be on their own line or not? What do you think about it?

```<code>if (you.hasAnswer()) {
    you.postAnswer();
} else {
    you.doSomething();
}
</code>```

or should it be

```<code>if (you.hasAnswer())
{
    you.postAnswer();
}
else
{
    you.doSomething();
}
</code>```

or even

```<code>if (you.hasAnswer())
    you.postAnswer();
else
    you.doSomething();
</code>```

Please be constructive! Explain why, share experiences, back it up with facts and references.

答:
I use the first style usually just to get more code into one screen view.  I never use the last it is just to easy to forget to add the {} if you add a second line of code.

Also these have a 'common' names the first one with the {} on the same line is K&R style and the second one with the {} on  the next line is Allman or BDS style.  (wikipedia indent style)

OwnerDisplayName: llcf


问:
Are there any conceptual drawbacks to building a web app with C++ and MySQL?
I've inherited a pretty interesting project where there is a good opportunity to take an existing piece of software and turn it into a SaaS web app. As the project is inherited, the code base/ framework is already defined as C++ and MySQL. The app itself is compiled and run as an EXE on Windows Server. The UI is web based and the app works as a kind of server. From what I do know of modern web apps, this is perhaps an unusual choice. These days, most people seem to opt for a PHP framework or Ruby on Rails. Certainly that is the impression I get from reading blogs on the subject. So, I'm very interested to know if a C++ EXE backed by MySQL is a solid foundation for a web app, or whether we should be looking to build in another way?</p>

答:
It certainly is an unusual choice. C++ wasn't designed with web applications in mind, and while libraries exist to write, say, FastCGI applications with C++, you have to do a lot more work to get your basic application up. "Web languages" usually do a lot of things for you that you have to get from elsewhere in C++, such as implementing the HTTP protocol, generating HTML, etc.

Also, web applications are mostly about strings, which isn't exactly C++'s strongest side - there is no string type built into the language itself, and this leads to a few quirks and makes string processing more clumsy than it would be in more high-level languages. Handling character encodings correctly in C++ borders on black magic. And C++ can crash really hard, on fairly innocent-looking code, which is far less likely with a higher-level language (they too can crash, but in most cases, the web server can recover gracefully, especially on platforms that use a per-request lifecycle model, like PHP).

That said, if you have most of the codebase written already, C++ might still be a viable choice. You will need to find some libraries to cover all sorts of web things (most notably, you want to be able to either integrate a standalone HTTP web server into your program, or hook into, say, Apache, either through FastCGI or by compiling to a module; you will also want some kind of templating library to make rendering HTML documents painless).

Finally, there's the developer market issue. There are plenty of C++ developers available, and even more web developers, but the overlap is probably not that large, so if you ever need to hire people to work on this thing, you'll have a somewhat harder time than with, say, PHP.


问:
How would you manage development between many Staging branches?
We have a Staging Branch. Then we came out with a Beta branch for users to move whenever they wanted to from old Production branch to the new features.

Our plan seemed simple, we test on Staging, when items get QA'd, they get cherry-picked and deploy to Beta.

Here's the problem! A bug will discreetly make its way on to Beta, and since Beta is a production environment, it needs fixes fast and accurate. But not all the QA's got done. Enter Git hell..

So I find a problem on Beta. No sweat, it's already been fixed on Staging, but when I go to cherry-pick the item over, Beta barely has any of the other pre-requisites of code to implement this small change. Now Beta has a little here and a little there, and I can't imagine it as a code base being as stable as Staging. What's more, is I'm dealing with some insane Git conflicts, and having to monkey patch a bunch of things to make up for what Beta hasn't caught up with Staging.

Can someone polite or non-polite terms, tell me what we're doing wrong here as far as assembling this project? Any awesome recommendations or workarounds or alternatives to the system we came up with?

答: You fix outright bugs in the Beta branch in Beta, not in Staging. Then you back port the fix from Beta to Staging, if necessary, before it gets overwritten.</p>


问:
How should I track approval workflow when users at every security level can create a request?
I am writing a new application that allows users to enter requests.

Once a request is entered, it must follow an approval workflow to be finally approved by a user the highest security level.

So, let's say a user at Security Level 1 enters a request. This request must be approved by his superior - a user at Security Level 2. Once the Security Level 2 user approves it, it must be approved by a user at Security Level 3. Once the Security Level 3 user approves it, it is considered fully approved.

However, users at any of the three Security Levels can enter requests. So, if a Security Level 3 user enters a request, it is automatically considered "fully approved". And, if a Security Level 2 user enters a request, it must only be approved by a Security Level 3 user.

I'm currently storing each approval status in a Database Log Table, like so:

```<code>STATUS_ID (PK) REQUEST_ID    STATUS           STATUS_DATE
-------------- ------------- ---------------- -----------------------
1              1             USER_SUBMIT      2012-09-01 00:00:00.000
2              1             APPROVED_LEVEL2  2012-09-01 01:00:00.000
3              1             APPROVED_LEVEL3  2012-09-01 02:00:00.000
4              2             USER_SUBMIT      2012-09-01 02:30:00.000
5              2             APPROVED_LEVEL2  2012-09-01 02:45:00.000
</code>```

My question is, which is a better design:

Record all three statuses for every request
...or...

Record only the statuses needed according to the Security Level of the user submitting the request

In Case 2, the data might look like this for two requests - one submitted by Security Level 2 User and another submitted by Security Level 3 user:

```<code>STATUS_ID (PK) REQUEST_ID    STATUS           STATUS_DATE
-------------- ------------- ---------------- -----------------------
1              3             APPROVED_LEVEL2  2012-09-01 01:00:00.000
2              3             APPROVED_LEVEL3  2012-09-01 02:00:00.000
3              4             APPROVED_LEVEL3  2012-09-01 02:00:00.000
</code>```

答:
Option 2 of course.

Why would you want to store extra garbage data?

It will just confuse things, and adds NO value.


问:
Hiring at start-ups vs established companies
I have always wondered about this and perhaps experienced folks here can comment on this. I always read that big established software companies such as Google, Microsoft, etc are always wary of hiring software engineers/(or other related professionals) who don't exactly meet the job requirements, and would rather turn down a close "Yes/Maybe" decision.

There's also the general perception that start-ups are generally more willing to hire such "less-than-perfect" employees. But to me this sounds counter-intuitive: start-ups are generally much smaller and resource constrained so they would actually need a "10/10" hire while established companies with bigger teams and more resources would be willing to take a (small) risk on a hire.

Anyone have any comments on this from first-hand experience?

Thanks,

答:
Having worked (and recruited for) a few start-ups I have to say my personal experience is that any start-up with their salt should be more fussy about programmers than a large corporate.

Paul Graham backs me up nicely in his great How to Make Wealth Essay:

Steve Jobs once said that the success or failure of a startup depends on the first ten employees. I agree. If anything, it's more like the first five. Being small is not, in itself, what makes startups kick butt, but rather that small groups can be select. You don't want small in the sense of a village, but small in the sense of an all-star team.

It is naturally a lot harder for start-ups to find suitable candidates. Pay is lower, risk is higher. But there are a surprising number of people who are attracted to the lack of corporate BS and being able to make a visible difference (early stock options help too.)


答:
has mandated that we develop this application in ANSI C. The rationale is that he is the only one that will be around the entire time, and therefore he must be able to understand what we are doing.

This is a pretty reasonable requirement.

He also ruled that we should use no abstract data types;

This doesn't make sense. Now it is starting to smell a bit suspicious, because this is a program design requirement and not a language requirement. If the code should be easy to maintain, implementing ADTs or using well-tested, pre-existing ones should be a priority.

he even gave us a list with the name of the global variables (sigh) he wants us to use.

Ok, so now it stinks. Now we can tell that your boss has limited experience not just from various programming languages, but from programming in general. A skilled veteran programmer, no matter language preference, would never make such a statement. (The only exception that I can think of is if most of the code is intended to run on a fairly small embedded system, and therefore that all necessary working memory for the code was expected to be pre-allocated.  The idea that the same code is expected to have a screen level UI argues against strongly that being the case, however).

I'm guessing that your boss has never been involved in large scale, mission critical software projects, but he has more likely been floating around in various low-quality ones.

So this has nothing to do with the programming language C. You can easily write equally icky programs in C# as well. It is a very common mistake to believe that good program design depends on the language. That is simply not true!

C# certainly has prettier, cleaner and less obscure syntax than C. It has plenty of program design support, since it has far more OO-related keywords than C. But apart from that, it does not tell you how to write your programs. If you believe that everything written in C is awful by default and everything written in C# is heaven by default, I bet you are currently writing rather awful C# programs without realizing it.

What I would suggest is that you make an abstract, language-independent, but detailed program design before anything else. Use the normal, object-oriented approach. What objects are there and how do they communicate between each other, what are the dependencies needed etc etc. When you have given the program design enough thought and gotten it down on paper, it shouldn't matter much to you nor to your boss which language you chose to implement it in.


答:
It is OK to make a web application using C++ IF the benefits outweighs the cost, obviously. Google, Amazon, Facebook are all built with C++ for efficiency in speed, memory and energy - aka servers costs.

However as you guessed, there are drawbacks to using C++ for this. It depends on your tools though.

First let me cite cppcms website on this:

When CppCMS Should Be Used.

C++ language is far from being popular for Web development for many
  reasons: lack of appropriate tools, skills of developers and many
  more.

However, there are areas where C++ web programming with CppCMS becomes
  very useful and efficient, and some where it is just a waste of time.

When CppCMS should or can be used?

1.High load web sites and application with hundreds and thousands hits
  per second, where high performance, efficiency and scalability is
  required.

2.Application that require scalable Comet/Server Push
  technologies --- CppCMS can efficiently handle hundreds and thousands
  simultaneous HTTP connection with minimal resources usage.

3.Embedding web interface into existing C++ applications/services with a small
  cost of additional library.

4.Embedded underpowered devices -- CppCMS
  allows creation of rich applications with relatively low cost of
  hardware that would perform reasonably fast.

When Not To Use?

If you create small web applications that do not require high loads
  and require very short time-to-market period -- probably tools like
  Django or RoR would be more appropriate for such tasks.

The drawbacks specific to C++ are:

Compile times can be very very very very slow compared to other languages. This might impact iterations, release interval but also developer's moral. Make sure it's worth it.

Most of the time, you need to compile changes. It can be avoided but it's the usual.

Writing modern C++ makes it easy (to learn, read, write, debug, etc.), but a lot of C++ developers don't know what is Modern C++. So if you work in team, you need to have good knowledge of Modern C++ from the whole team. If not, you will easily get into very complicated bugs. That said, it's more a people problem than a language problem. It's just that C++ history didn't help make it easy to grasp. Good teaching is not as common as in more modern (historically) languages.

Unicode is still poorly supported by the core C++ language, making it a potential source of great pain. Just use UTF-8 everywhere and some libraries (look into boost) to manage it.

C++ standard don't know what is a library. So we use conventional ways to manage them on different compiler/linker/OS. This might be a problem if you start to get into cross-platform code that need to load/unload "on the fly" some modules.

Maybe take a look at CPPCMS? Or maybe wt if you want to make a GUI-style website?

Also check these questions:

Are C and/or C++ viable/practical options for web development?

Can C++ be used as a server-side web development language?

Thoughts on web development architecture through integrating C++ in the future to a web application

Title: Are there any conceptual drawbacks to building a web app with C++ and MySQL?

Body: I've inherited a pretty interesting project where there is a good opportunity to take an existing piece of software and turn it into a SaaS web app. As the project is inherited, the code base/ framework is already defined as C++ and MySQL. The app itself is compiled and run as an EXE on Windows Server. The UI is web based and the app works as a kind of server. From what I do know of modern web apps, this is perhaps an unusual choice. These days, most people seem to opt for a PHP framework or Ruby on Rails. Certainly that is the impression I get from reading blogs on the subject. So, I'm very interested to know if a C++ EXE backed by MySQL is a solid foundation for a web app, or whether we should be looking to build in another way?</p>


问:
What ever happened to the Defense Software Reuse System (DSRS)?
I've been reading some papers from the early 90s about a US Department of Defense software reuse initiative called the Defense Software Reuse System (DSRS). The most recent mention of it I could find was in a paper from 2000 - A Survey of Software Reuse Repositories

Defense Software Repository System (DSRS)

The DSRS is an automated repository for storing and retrieving Reusable Software Assets (RSAs) [14]. The DSRS software now manages inventories of reusable assets at seven software reuse support centers (SRSCs). The DSRS serves as a central collection point for quality RSAs, and facilitates software reuse by offering developers the opportunity to match their requirements with existing software products.
  DSRS accounts are available for Government employees and contractor personnel currently supporting Government projects...

...The DoD software community is trying to change its software engineering model from its current software cycle to a process-driven, domain-specific, architecture-based, repository-assisted way of constructing software [15]. In this changing environment, the DSRS has the highest potential to become the DoD standard reuse repository because it is the only existing deployed, operational repository with multiple interoperable locations across DoD. Seven DSRS locations support nearly 1,000 users and list nearly 9,000 reusable assets. The DISA DSRS alone lists 3,880 reusable assets and has 400 user accounts...

The far-term strategy of the DSRS is to support a virtual repository. These interconnected repositories will provide the ability to locate and share reusable components across domains and among the services. An effective and evolving DSRS is a central requirement to the success of the DoD software reuse initiative. Evolving DoD repository requirements demand that DISA continue to have an operational DSRS site to support testing in an actual repository operation and to support DoD users. The classification process for the DSRS is a basic technology for providing customer support [16]. This process is the first step in making reusable assets available for implementing the functional and technical migration strategies.

...

  [14] DSRS - Defense Technology for Adaptable, Reliable Systems

  URL: http://ssed1.ims.disa.mil/srp/dsrspage.html

  [15] STARS - Software Technology for Adaptable, Reliable Systems

  URL: http://www.stars.ballston.paramax.com/index.html

  [16] D. E. Perry and S. S. Popovitch, “Inquire: Predicate-based use and reuse,''

  in Proceedings of the 8th Knowledge-Based Software Engineering Conference, pp. 144-151, September 1993.

  ...

Is DSRS dead, and were there any post-mortem reports on it? Are there other more-recent US government initiatives or reports on software reuse?

答: As a Java programmer working for the Dept of Defense, I've never heard of it and neither has anyone else in the office.  I just now Googled it and all I found was the acronym definition but nothing else.  I think its safe to say that it died a quiet death.  Pity, though, it seems like a good idea.</p>


问:
How can I convince my boss that ANSI C is inadequate for our new project?
A few months ago, we started developing an app to control an in-house developed test equipment and record a set of measurements. It should have a simple UI, and would likely require threads due to the continuous recording that must take place. This application will be used for a few years, and shall be maintained by a number of computer science students during this period.

Our boss graduated some 30 years ago (not to be taken as an offense; I have more than half that time on my back too) and has mandated that we develop this application in ANSI C. The rationale is that he is the only one that will be around the entire time, and therefore he must be able to understand what we are doing. He also ruled that we should use no abstract data types; he even gave us a list with the name of the global variables (sigh) he wants us to use.

I actually tried that approach for a while, but it was really slowing me down to make sure that all pointer operations were safe and all strings had the correct size. Additionally, the number of lines of code that actually related to the problem in hand was a only small fraction of our code base. After a few days, I scrapped the entire thing and started anew using C#. Our boss has already seen the program running and he likes the way it works, but he doesn't know that it's written in another language.

Next week the two of us will meet to go over the source code, so that he "will know how to maintain it". I am sort of scared, and I would like to hear from you guys what arguments I could use to support my decision.

Cowardly yours,

答:
Oh dear.   This is a real-time application?  Controlling equipment in real time?   Gathering data in real-time?   Using a language with a garbage collector?   Oh dear.

While I agree that you can probably do the app in a more modern language in less time, that's probably not the major criterion.   EASE OF YOUR PROGRAMMING IS PROBABLY MUCH LESS IMPORTANT THAN THE OTHER CRITERIA, such as the ones your boss laid down, AND response time, and deterministic behavior.

I would have suggested you do a prototype in C# or Python, just to test out the main functionality and UI.  THEN test the heck out of it, measuring actual latencies and response times, when the app gets hit with a lot of data, over many days of continuous running.   Odds are, the app could end up being too slow or fall behind at random times, when VM or the garbage collector kicks in.

I suggest you present what you've done as a PROTOTYPE.

Coding in C isn't that hard.  If you're not up to it, say so.  There's plenty of us up for the challenge.  ( I've been doing real-time C coding for, argh, decades now ).


答:
I would consider having "auto-approved" tags for the cases where a Level 2 or 3 user creates a request.

My presumption is that you are tracking:

who creates

who approves at level 2

who approves at level 3

So your status could then go through the following:

User_submit

Approved_Level2 or Auto_Approved_L2

Approved_Level3 or Auto_Approved_L3

That would allow you to keep track of cases where things are auto-approved, but still maintain the same / similar code paths for all work tickets.  So that should meet your requirements and store meaningful information.  Presuming you care about cases between an actual approval and an auto approval.

So I'm voting for a modified version of case 1.

Title: How should I track approval workflow when users at every security level can create a request?

Body:
I am writing a new application that allows users to enter requests.

Once a request is entered, it must follow an approval workflow to be finally approved by a user the highest security level.

So, let's say a user at Security Level 1 enters a request. This request must be approved by his superior - a user at Security Level 2. Once the Security Level 2 user approves it, it must be approved by a user at Security Level 3. Once the Security Level 3 user approves it, it is considered fully approved.

However, users at any of the three Security Levels can enter requests. So, if a Security Level 3 user enters a request, it is automatically considered "fully approved". And, if a Security Level 2 user enters a request, it must only be approved by a Security Level 3 user.

I'm currently storing each approval status in a Database Log Table, like so:

```<code>STATUS_ID (PK) REQUEST_ID    STATUS           STATUS_DATE
-------------- ------------- ---------------- -----------------------
1              1             USER_SUBMIT      2012-09-01 00:00:00.000
2              1             APPROVED_LEVEL2  2012-09-01 01:00:00.000
3              1             APPROVED_LEVEL3  2012-09-01 02:00:00.000
4              2             USER_SUBMIT      2012-09-01 02:30:00.000
5              2             APPROVED_LEVEL2  2012-09-01 02:45:00.000
</code>```

My question is, which is a better design:

Record all three statuses for every request
...or...

Record only the statuses needed according to the Security Level of the user submitting the request

In Case 2, the data might look like this for two requests - one submitted by Security Level 2 User and another submitted by Security Level 3 user:

```<code>STATUS_ID (PK) REQUEST_ID    STATUS           STATUS_DATE
-------------- ------------- ---------------- -----------------------
1              3             APPROVED_LEVEL2  2012-09-01 01:00:00.000
2              3             APPROVED_LEVEL3  2012-09-01 02:00:00.000
3              4             APPROVED_LEVEL3  2012-09-01 02:00:00.000
</code>```


答:
I would say it is inconsiderate. Editor settings shouldn't have an impact on the compiled executable (except for cases where editor settings affect things such as multi-line string literals). I chose the editor settings that I have because I like them that way. If I check out a code file and suddenly my editor behaves in a manner that I am not used to, I am not going be happy at all. How would you feel in a similar situation, if my unfamiliar editor settings suddently overrode yours?

I think if you want to check in editor settings, the best thing would be to have them in a separate file and make it very clear that the file will change the user's current editor settings, and that it is optional to use this file.

If you are concerned about new individuals following an established group standard for code formatting, you can ask everyone to format the code according to the standard on check-in. I think some source control systems might support such an auto-format automatically, but I'm not sure.


答:
Wordpress running in PHP with a few plugins installed brings my Winders server to it's knees. So I have no problems at all with the idea of implementing a web application in C++. Speed is a critical part of the web experience.

Graphic design tents to drive the majority of web projects. PHP is an obscure scripting language that runs inside HTML. Allowing the PHP authors to escape in and out of HTML. There are many benefits with working with HTML as a result.

Still, you could implement any number of HTML template solutions in C++.

One could provide you with an long list of Python and PHP frameworks that make for rapid development, but if you have lots of time then C++ is definitely possible.

What I don't understand is your decision to do C++ on Windows. lol


答:
DSRS had at least one name before that and has had a couple more afterward.  I've since forgotten what they are, but you should consider the program dead.  Not even pining for the fjords, just dead.

The DoD has gone through many attempts at department-wide reusability programs, and this was one of them.  The Ada programming language was another, being a mandatory-use language from 1987 until the late 1990s when the mandate was effectively abandoned.  (The number of waivers for non-Ada projects that were being issued by the early 1990s should have been a dead giveaway.)

The post-mortem on most of these programs is pretty simple:

Trying to do re-use on that scale is a noble idea and can be made to work, but it takes a combination of foresight, determination, coordination and leadership that DoD has never been able to muster.

There were (and still are) cultural problems with re-use like turf wars between the department's offices and each of those offices running their own re-use programs.

A lot of defense-related development happens in a bubble, where the contractor is being paid to develop "a" system and doesn't have any real motivation to make the things they build into tools that can be used widely, especially if they're not going to be paid to maintain it for other programs over the long term.  Project A isn't going to use its precious budget to do something to help out Project B even though it's all the same big pot of money.

Title: What ever happened to the Defense Software Reuse System (DSRS)?

Body:
I've been reading some papers from the early 90s about a US Department of Defense software reuse initiative called the Defense Software Reuse System (DSRS). The most recent mention of it I could find was in a paper from 2000 - A Survey of Software Reuse Repositories

Defense Software Repository System (DSRS)

The DSRS is an automated repository for storing and retrieving Reusable Software Assets (RSAs) [14]. The DSRS software now manages inventories of reusable assets at seven software reuse support centers (SRSCs). The DSRS serves as a central collection point for quality RSAs, and facilitates software reuse by offering developers the opportunity to match their requirements with existing software products.
  DSRS accounts are available for Government employees and contractor personnel currently supporting Government projects...

...The DoD software community is trying to change its software engineering model from its current software cycle to a process-driven, domain-specific, architecture-based, repository-assisted way of constructing software [15]. In this changing environment, the DSRS has the highest potential to become the DoD standard reuse repository because it is the only existing deployed, operational repository with multiple interoperable locations across DoD. Seven DSRS locations support nearly 1,000 users and list nearly 9,000 reusable assets. The DISA DSRS alone lists 3,880 reusable assets and has 400 user accounts...

The far-term strategy of the DSRS is to support a virtual repository. These interconnected repositories will provide the ability to locate and share reusable components across domains and among the services. An effective and evolving DSRS is a central requirement to the success of the DoD software reuse initiative. Evolving DoD repository requirements demand that DISA continue to have an operational DSRS site to support testing in an actual repository operation and to support DoD users. The classification process for the DSRS is a basic technology for providing customer support [16]. This process is the first step in making reusable assets available for implementing the functional and technical migration strategies.

...

  [14] DSRS - Defense Technology for Adaptable, Reliable Systems

  URL: http://ssed1.ims.disa.mil/srp/dsrspage.html

  [15] STARS - Software Technology for Adaptable, Reliable Systems

  URL: http://www.stars.ballston.paramax.com/index.html

  [16] D. E. Perry and S. S. Popovitch, “Inquire: Predicate-based use and reuse,''

  in Proceedings of the 8th Knowledge-Based Software Engineering Conference, pp. 144-151, September 1993.

  ...

Is DSRS dead, and were there any post-mortem reports on it? Are there other more-recent US government initiatives or reports on software reuse?


答:
You have completely failed to convince us that ANSI C was inadequate. C is an excellent language that seems adapted for the kind of tasks you have described. With the short description of the task (except the language requirement), I would also recommend C (or maybe go).

I think the problem is that you were programming in C with your mind thinking in C#. I have a similar problem when I switch from Perl to C or java. You must learn to adapt to the language, and not learn to translate from your way of thinking toward the language of the day.

The problem is not your boss or the C language, the problem is to open your mind toward different ways of thinking. Changing programming language is something that will benefit you.


问:
What is happening to PHP 6?
I am excited about the changes in PHP 6 previewed in PHP 5.3+. However, I wonder why it takes so long to release PHP 6? Books about it have been published since 2008, and announcements on it since 2007, but I am yet to hear about an alpha or a beta. Why does it take so long to release it? Or is that the way it goes with all languages when they transition to a major release where I guess it takes around 4-5 years to release?</p>

答:
The release timetable is not unusual for languages, and it's not even that unusual for PHP: 5.0 was released in 2004, but 4.0 was released in 2000.

Compare this to the last stable releases for C (2000), Fortran (2003), or C++ (2003).

One other thing to keep in mind is that 5.3 was a major release in all but name. It adds a lot of stuff that was originally destined for PHP 6. Due to development problems with unicode support (a major part of PHP 6), it was decided to release what was stable at the time as a 5.x branch.

Title: What is happening to PHP 6?


问:
Why does Javascript use JSON.stringify instead of JSON.serialize?
I'm just wondering about "stringify" vs "serialize". To me they're the same thing (though I could be wrong), but in my past experience (mostly with asp.net) I use Serialize() and never use Stringify().

I know I can create a simple alias in Javascript,

```<code>// either
JSON.serialize = function(input) {
    return JSON.stringify(input);
};

// or
JSON.serialize = JSON.stringify;
</code>```

http://jsfiddle.net/HKKUb/

but I'm just wondering about the difference between the two and why stringify was chosen.

for comparison purpose, here's how you serialize XML to a String in C#

```<code>public static string SerializeObject<T>(this T toSerialize)
{
    XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType());
    StringWriter textWriter = new StringWriter();

    xmlSerializer.Serialize(textWriter, toSerialize);
    return textWriter.ToString();
}
</code>```

答:
This is because that JSON notation was specified in 1999 not after 2002 (asp.net is released at that year). so i guess they didn't know about the serialize.

Jokes apart,

Hearing the word serialization, first thing that comes to my mind is  like converting the data to bytes, here JSON.stringify makes perfect sense as it converts the object to a string representation not a byte representation.

PS:

@Chase Florell, you can't just add JSON.serialize, as in strict mode, this code may actually fail in some browsers.

as JSON is not your average Object.


问:
Naming variables with fixed point units
What should I name a variable that has units with a  fixed point?

```<code>int herpLimitLo_psig2 = 6000; // 60.00 psig
int derpLimitLoPsigwithtwodigits;
int herpLimitHiPsigfixedtwo;
int herpLimitHi_psig_timesOneHundred;
</code>```

Apparently I suck at naming things.

答:
what about naming the variable according to its meaning in the current context? You should avoid naming variables after their type.

The only important information you should be able to retrieve easily is the interpretation factor. In most cases, there will be only one, so you can define a constant and use it everywhere you need it (and avoid putting it in the variable names).

If you are using a lot of different precisions in your computations, you should use a specific type for fixed point computations.

At least in debug mode, this type should be able to give you the precision of a given variable, and prevent you to do stuff like adding two numbers with different precisions (at least in debug mode). And so you are also free to give your variable a short meaningful name.

example in python:

```<code>speed = FixedPoint(precShift=5, val=64) # --> 2 m/sec
duration = FixedPoint(precshift=2, val=5) # --> 2.5 sec
length = speed * duration # precShift=7, value=320
</code>```

Title: Naming variables with fixed point units

Body:
what about naming the variable according to its meaning in the current context? You should avoid naming variables after their type.

The only important information you should be able to retrieve easily is the interpretation factor. In most cases, there will be only one, so you can define a constant and use it everywhere you need it (and avoid putting it in the variable names).

If you are using a lot of different precisions in your computations, you should use a specific type for fixed point computations.

At least in debug mode, this type should be able to give you the precision of a given variable, and prevent you to do stuff like adding two numbers with different precisions (at least in debug mode). And so you are also free to give your variable a short meaningful name.

example in python:

speed = FixedPoint(precShift=5, val=64) # --> 2 m/sec
duration = FixedPoint(precshift=2, val=5) # --> 2.5 sec
length = speed * duration # precShift=7, value=320


问:
How do I Export to excel on aspx page?
I am trying to take data that I request from an access database and put it into and excel file on the client computer.

I usually use ajax to request a summary of the data I need. It is formatted into an html table.

I need that table to be in an excel format for the user to download.

What I have tried already is to use the vb.net code to open excel and silently save the data to a file, however I realized it's the server side that opens excel, not the client side, in my locally testing of the code, excel would open on my machine and create the file.

When running this on the network, I realized excel isn't on the server, I am not sure if I should just install it or try stream the file?

答: The easiest way to do this without installing excel on the server is to dump the data to a csv(or tab delimited) file format and serve it to the client which can be opened with excel. Installing excel on a server may not be possible due to network policies and licensing issues.</p>

Title: How do I Export to excel on aspx page?


答:
The supervisor aversion to ADTs was addressed elsewhere, as was the dev's seeming unawareness of GC costs, so I'll focus on "threads".

Perhaps rather than thinking in terms of .NET (or JVM, if so indoctrinated) threading, what you may want is multiple processes, using some inter-process communication (IPC) mechanism to communicate between them.  E.g - windows messages, shared memory, memory mapped file buffer, named pipe, whatever.  Dedicate small processes to interacting with a device or aspect of the device and checking the IPC to communicate updates and acknowledge requests, and have a somewhat larger process to maintain the GUI and communicate with the equipment "monitors" using whatever IPC you select.


答:
Just herpLimitLo is enough.

Variable names are expensive; you can't make them too long or your code will be unreadable (after all, excessive repetition of excessively redundant information excessively causes excessive exceeding of the human brain's excessiveness processing systems if used excessively), but you do want them to be as descriptive as possible. This means that you should name them after their meaning; things like expected value range or value semantics can be expressed through other language features in almost every programming language.

For example, in C, you can use typedef; even if the variable's "real" type is still int, writing it as fixed_2 herpLimitLo suggests what it is. In a language with more sophisticated type systems, whether dynamic or static, you can define an actual type for your base-2 fixed-point numbers. Depending on the language, you can then even overload common numeric operations to work transparently with such fixed-point numbers.

Some languages will even refuse to compile your code if you do stupid things like trying to directly assign a float to a fixed_2, provided you do in fact define them as different types - no naming convention in the world can do that for you.

Title: Naming variables with fixed point units

Body:
What should I name a variable that has units with a  fixed point?

```<code>int herpLimitLo_psig2 = 6000; // 60.00 psig
int derpLimitLoPsigwithtwodigits;
int herpLimitHiPsigfixedtwo;
int herpLimitHi_psig_timesOneHundred;
</code>```

Apparently I suck at naming things.


答:
You need to Stream it out via HTTP.
See : How to export Excel file to browser from your ASP.NET applications?

Your other option is to save the file on webserver (within the web app), then provide the user with a link to it. You could then have a process that deletes the "Dead" files every so often.

Title: How do I Export to excel on aspx page?

Body:
I am trying to take data that I request from an access database and put it into and excel file on the client computer.

I usually use ajax to request a summary of the data I need. It is formatted into an html table.

I need that table to be in an excel format for the user to download.

What I have tried already is to use the vb.net code to open excel and silently save the data to a file, however I realized it's the server side that opens excel, not the client side, in my locally testing of the code, excel would open on my machine and create the file.

When running this on the network, I realized excel isn't on the server, I am not sure if I should just install it or try stream the file?


问:
Is there a precedent for the license on a compiler restricting the kind of development you can use it for?
It was recently let slip that the new EULA for Delphi XE3 will prohibit Client Server development with the Professional edition without the additional purchase of a Client Server license pack. This is not to say the Professional version will lack the features, but the license will specifically prohibit the developer from using the compiler for a specific class of development, even with 3rd party or home grown solutions.

So my question is if there is a precedent of a compiler or similar creative tool prohibiting the class of work you can use it for. Specifically a commercially licensed "professional" tool like Delphi XE3. Also, would such a restriction be legally enforceable?

I know there have been educational edition or starter edition tools in the past that have restricted their use for commercial purposes, but those were not sold as "professional" tools. Also I know that a lot of computing software and equipment will have a disclaimer that it is not for use in "life support equipment" or "nuclear power" but that is more of avoiding liability than prohibiting activity.

Seems like I recall Microsoft putting a restriction in FrontPage that you couldn't use it to create a web site that reflected poorly on Microsoft, but they pulled that restriction before it could be tested legally.

Update: The EULA was dropped before the product shipped because of public resistance.

答:
Java has long had a restriction against use in nuclear facilities, although the JDK6 license agreement softened the terms slightly (I recall the older variants being much more explicit):

You acknowledge  that Licensed  Software is not designed or
  intended for use in the design, construction, operation or maintenance
  of any nuclear facility.  Oracle Corporation  disclaims any express or
  implied  warranty  of  fitness  for such  uses.

This makes sense: you wouldn't want to let a GC pause get in the way of SCRAMing the reactor. Which is not to say that there isn't someone, somewhere, who has accepted a contract for nuclear control systems and decided that it was cheaper/easier to hire Java programmers.


问:
What are the most known arbitrary precision arithmetic implementation approaches?
I'm going to write a class library for .NET which provide an implementation of arbitrary precision arithmetic for integer, rational and maybe complex numbers. What best known approaches should I become familiar with?

I tried to start with Knuth's TAOCP Vol.2 (Seminumerical Algorithms, Chapter 4 – Arithmetic) but it's too complicated. At least I couldn't get the ideas in a relatively short period of time.

答:
Addressing the question about why there's BigInteger but not BigReal, etc.: this has to do with the arbitrary nature of floating point representation.  The IEEE standard for 64-bit floating point sets aside some of the bits for the exponent ("characteristic") and the "whole" number part ("mantissa").  There is a standard for extended precision floating point but it seems general: http://en.wikipedia.org/wiki/IEEE_754-2008#Extended_and_extendable_precision_formats.

So, extending floating point requires arbitrary decisions about how large to make the parts of the number whereas extension of integers is straightforward: just keep adding high-order digits as necessary.  For this reason, it makes sense to look at rationals (a ratio of extended-precision integers) rather than floating point.  Take a look here - http://www.jsoftware.com/jwiki/Essays/Extended%20Precision%20Functions - for some high-level considerations on this.