问:
We are moving an Access based corporate front-end into a Web-based App
We have an enterprise application with a front end written in Microsoft Access 2003 that has evolved over the past 6 years.  The back end data, and a fair amount of back-end logic is contained within several Microsoft SQL Server databases.  This front end app consists of around 180 forms, and over 120,000 lines of code, and interacts with VB.Net DLLs that support various critical functions used by our sales force.  The current system makes use of 3 monitors to display various information; the Access app uses COM+ to control Microsoft Outlook and Internet Explorer for various purposes.  The Access front end sometimes occupies 2 screens, automatically resizing itself based on Windows API-reported screen dimensions.  The app also uses a Google map to present data to our agents, and allows two-way interactivity with the map through COM+ connectivity to JavaScript contained in the Google map.

At the urging of senior management, we are looking to completely rewrite this application using some web-based technology, such as ASP.Net or perhaps a LAMP stack (the thinking with the LAMP stack thing is "free" is pretty cheap).

We want to move to a web-based app so we can eliminate the dependency on our physical location for hiring new sales force members.  Currently, our main office is full to capacity, and we need to continue growing the company.

Does anyone have any thoughts on what would be the best technology to use for a web-based app of this magnitude?  Keeping in mind the app is dependent on back-end services on our existing infrastructure.  The app handles financial data and personal customer data, among other things.

[I've looked at Best practices for moving large MS Access application towards .Net? and read the answers, and most of the comments.  Interesting reading, and has some valid points, but our C.O.O. and contracted Software Architect are pushing for a full web-based app, not a .Net Windows App]

答:
Of course, without knowing the complexity of your application (and the interfaces with Outlook, IE, etc suggest to me that it IS complex), I would recommend the .NET route, since it appears you're already familiar with a lot of the Visual Studio tools that would be involved. (SQL Server, VB.Net, etc)

While I am not anti-open source, (I like FREE, too), it depends on what you want to bite off.  Do the developers in your shop have more experience in the Visual Studio realm, or in the LAMP realm?  Is the licensing cost for Visual Studio what is driving people in that direction, or is there a valid technical reason (everyone has to learn all new stuff anyway, and LAMP gives us [significant value item here] and [significant bonus value here] that make it a better choice as we go through the process of change)?

This really depends on how much money is budgeted, how much time you have to do the work, and what the new application will actually do that might be different from the existing application.  Sometimes the "free" tools will actually cost more in the time required to learn them and integrate them with what you already have.


问:
How to take a step back and look at code with fresh eyes?
I've spent the last year as a one-man team developing a rich-client application (35,000+ LoC, for what it's worth). It's currently stable and in production. However, I know that my skills were rusty at the beginning of the project, so without a doubt there are major issues in the code. At this point, most of the issues are in architecture, structure, and interactions -- the easy problems, even architecture/design problems, have already been weeded out.

Unfortunately, I've spent so much time with this project that I'm having a hard time thinking outside of it -- approaching it from a new perspective to see the flaws deeply buried or inherent in the design.

How do I step outside my head and outside my code so I can get a fresh look and make it better?

答: Rubber duck debugging: Sit down with a piece of code or a module or a feature and explain it, out loud. When you find yourself saying something that sounds wrong, foolish, or just plain not right write it down as an issue to investigate.

ContentLicense: CC BY-SA 3.0


问:
What technologies are used for Game development now days?
Whenever I ask a question about game development in an online forum I always get suggestions like learning line drawing algorithms, bit level image manipulation and video decompression etc.

However looking at games like God of War 3, I find it hard to believe that these games could be developed using such low level techniques.

The sheer awesomeness of such games defy any comprehensible(for me) programming methodology.

Besides the gaming hardware is really a monster now days. So it stands to reason that the developers would work at a higher level of abstraction.

What is the latest development methodology in the gaming industry? How is it that a team of 30-35 developers (of which most is management and marketing fluff) able to make such mind boggling games?

If the question seems too general could you explain the architecture of God of War 3? Or how you would go about producing a clone? That I think should be objectively answerable.

答:
The answer is "engines". A lot fo games are built ontop of various graphics and gameplay engines that are basically, big libraries or frameworks.

In the OSS world, take a look at Ogre for an example, for commercial games you have stuff like Source.

There are other factors at play, like a lot of the code is disposable and wouldn't pass muster in a business environment - but that's because the limited lifespan of a game, and the accelerated development timescales, mean the code is (almost) designed just to work, not to be maintained.


答:
First, keep in mind that the LAMP stack might be free to get rolling on but that the costs of ownership are still effectively the same. You still need to feed the servers power and bandwidth and you still need skilled labor to keep things running and secure. Once you get to big enough scale it is pretty much a wash.

I would argue in this case that while making it somewhat web-based could make alot of sense, you'll probably be looking at something with a central service with several UIs. Moreover, the thing I'd think about more than web is mobile -- how are you handling that? Web is yesterday, mobile is tomorrow.

Insofar as answering the question, I don't think there is a direct one given the facts we know. But in general these days you often must look towards hybrid approaches as most often you'll need to use bits and pieces of various stacks for the best and most cost-effective functionality.

Title: We are moving an Access based corporate front-end into a Web-based App

Body:
We have an enterprise application with a front end written in Microsoft Access 2003 that has evolved over the past 6 years.  The back end data, and a fair amount of back-end logic is contained within several Microsoft SQL Server databases.  This front end app consists of around 180 forms, and over 120,000 lines of code, and interacts with VB.Net DLLs that support various critical functions used by our sales force.  The current system makes use of 3 monitors to display various information; the Access app uses COM+ to control Microsoft Outlook and Internet Explorer for various purposes.  The Access front end sometimes occupies 2 screens, automatically resizing itself based on Windows API-reported screen dimensions.  The app also uses a Google map to present data to our agents, and allows two-way interactivity with the map through COM+ connectivity to JavaScript contained in the Google map.

At the urging of senior management, we are looking to completely rewrite this application using some web-based technology, such as ASP.Net or perhaps a LAMP stack (the thinking with the LAMP stack thing is "free" is pretty cheap).

We want to move to a web-based app so we can eliminate the dependency on our physical location for hiring new sales force members.  Currently, our main office is full to capacity, and we need to continue growing the company.

Does anyone have any thoughts on what would be the best technology to use for a web-based app of this magnitude?  Keeping in mind the app is dependent on back-end services on our existing infrastructure.  The app handles financial data and personal customer data, among other things.

[I've looked at Best practices for moving large MS Access application towards .Net? and read the answers, and most of the comments.  Interesting reading, and has some valid points, but our C.O.O. and contracted Software Architect are pushing for a full web-based app, not a .Net Windows App]


问:
Is using a bigger buffer useful?
I use buffer for quite a long time when I need to copy a stream or read a file.

And every time I set my buffer size to 2048 or 1024, but from my point of view a buffer is like a "bucket" which carries my "sand" (stream) from one part of my land (memory) to an other part.

So, increase my bucket capacity will in theory allow me to do less travel? Is this a good things to do in programming?

答:
The answer is: it depends. Unfortunately, there is NO single answer to your question. The number of variables (which include the speed of the hardware, the source of the stream, the type of the disk the file is being read from, memory available, OS file caching algorithm, etc, etc) all affect the answer.

For particular situations, I advise performance measurement to see if a bugger buffer helps.

Title: Is using a bigger buffer useful?


问:
How to correctly write an installation or setup document
I just joined a small start-up as a software engineer after graduation. The start-up is 4 year old, and I am working with the CEO and the COO, even if there are some people abroad. Basically they both used to do almost everything. I am currently on some kind of training phase. I have at my disposition architecture, setup and installation internal documentation. Architecture documentation is like a bible and should contain complete information. The rest are used to give directions in different processes.

The issue is that these documents are more or less dated, as they just didn't have the time to change them. I will be in charge of training the next hires, and updating these documents is part of my training. In some there is a lot of hard-coded information like:

```<code> Install this_module_which_still_exists
     cd this_dir_name_changed
     cp this_file_name_changed other_dir_name_changed
     ./config_script.sh
     ./execute_script.sh
</code>```

The issues i have faced :

Either the module installation is completely different (for instance now there is an rpm, or a different OS)

Either names changed, and i need to switch old names by new names

Description of the purpose of the current step missing.

Information about a whole topic is missing

Fortunately these guys are around and I get all the information I want and all the explanations I need. I want to bring a design to the next documents so in the future people don't feel like they are completely rewriting a document each time they are updating it.

Do you have suggestions?
If there is a lightweight design methodology available online you can point me to it's nice too.

One thing I will do for sure is set up a versioning repository for the documents alone. There is already one for the source code so I don't know why internal documents deserve a different treatment.

答:
Technically, I think a decent wiki platform is the best choice for most of this sort of documentation. Easy to get at, easy to fill in, good search and version history are all great features for this task. Exactly which platform isn't important -- I'd run with whatever is in place first. </p>

<p>The best advice I've heard on this sort of thing is that the most experienced people in the shop should write it, and the least experienced people in the shop should test it so you can find what the team leads skip over. </p>

Body:
Technically, I think a decent wiki platform is the best choice for most of this sort of documentation. Easy to get at, easy to fill in, good search and version history are all great features for this task. Exactly which platform isn't important -- I'd run with whatever is in place first.

The best advice I've heard on this sort of thing is that the most experienced people in the shop should write it, and the least experienced people in the shop should test it so you can find what the team leads skip over.


问:
How relevant is UTF-7 when it comes to parsing emails?
I recently implemented incoming emails for an application and boy, did I open the gates of hell? Since then every other day an email arrives that makes the app fail in a different way.

One of those things is emails encoded as UTF-7. Most emails come as ASCII, some of the Latin encodings, or thankfully, UTF-8.

Hotmail error messages (like email address doesn't exist or quota exceeded) seem to come as UTF-7. Unfortunately, UTF-7 is not an encoding Ruby understands:

```<code>> "hello world".encode("utf-8", "utf-7")
Encoding::ConverterNotFoundError: code converter not found (UTF-7 to UTF-8)

> Encoding::UTF_7
 => #<Encoding:UTF-7 (dummy)>
</code>```

My application doesn't crash, it actually handles the email quite well, but it does send me a notification about the potential error.

I spent some time googling and I can't find anyone that implemented the conversion, at least not as a Ruby 1.9.3 Encoding::Converter.

So, my question is, since I never got an email with actual content, from an actual person, in UTF-7, how relevant is that encoding? can I safely ignore it?

答:
The only relevant feature of UTF-7 (over UTF-8 for example) is that it's a 7-bit encoding, just like good old ASCII is. That means that it works over a system that is not 8-bit clean.

The only large-scale system where this even matters today is mail servers (don't ask me why they didn't fix this problem 10-20 years ago, most servers did, but some ostensibly still didn't).

So: UTF-7 will only have relevancy in email systems. Everywhere else UTF-8 is the better choice.


答:
We want to move to a web-based app so we can eliminate the dependency on our physical  location for hiring new sales force members.

If that is the main motivation behind your project, please consider not to rewrite the application. If I got your right, you will still have a defined user base, and don't want your app to be opened to millions of users (that's what web applications are best for). You also want access to the data only through secured channels.

In such a situation, I guess it will be at least 100x cheaper and quicker to provide all of your sales force members with a windows laptop and a VPN access to your network, and install the application directly on their machines. If deployment of updates seems to be a problem, think about writing an MSI conformant setup for your application and make use of windows policies for automatic deployment.

Also, I would heavily recommend this article of Joel on the topic of "rewrites": http://www.joelonsoftware.com/articles/fog0000000069.html

Of course, since your backend is a full relational database which can be accessed by many different applications simultaneously, it may be an approach to add new functionality through a web based frontend, as long as that new functionality is not very tight to existing functionality in Access application. Choose whatever technology fits best into your current knowledge stack.


答: There is an optimal size to a buffer. Too small a buffer can trigger more system calls than necessary, while too big a buffer can trigger unnecessary reloads of the CPU cache. The best way to answer this question for your specific situation is to use a profiler.</p>

Title: Is using a bigger buffer useful?

Body:
I use buffer for quite a long time when I need to copy a stream or read a file.

And every time I set my buffer size to 2048 or 1024, but from my point of view a buffer is like a "bucket" which carries my "sand" (stream) from one part of my land (memory) to an other part.

So, increase my bucket capacity will in theory allow me to do less travel? Is this a good things to do in programming?


答:
Thanks to Charles Salvia's comment, I found a method in the IMAP module that helped:</p>

```<code>require "net/imap"
Net::IMAP.decode_utf7(mail_body)
</code>```

Title: How relevant is UTF-7 when it comes to parsing emails?

Body:
I recently implemented incoming emails for an application and boy, did I open the gates of hell? Since then every other day an email arrives that makes the app fail in a different way.

One of those things is emails encoded as UTF-7. Most emails come as ASCII, some of the Latin encodings, or thankfully, UTF-8.

Hotmail error messages (like email address doesn't exist or quota exceeded) seem to come as UTF-7. Unfortunately, UTF-7 is not an encoding Ruby understands:

```<code>> "hello world".encode("utf-8", "utf-7")
Encoding::ConverterNotFoundError: code converter not found (UTF-7 to UTF-8)

> Encoding::UTF_7
 => #<Encoding:UTF-7 (dummy)>
</code>```

My application doesn't crash, it actually handles the email quite well, but it does send me a notification about the potential error.

I spent some time googling and I can't find anyone that implemented the conversion, at least not as a Ruby 1.9.3 Encoding::Converter.

So, my question is, since I never got an email with actual content, from an actual person, in UTF-7, how relevant is that encoding? can I safely ignore it?

Body:
Thanks to Charles Salvia's comment, I found a method in the IMAP module that helped:

require "net/imap"
Net::IMAP.decode_utf7(mail_body)


答:
What is the problem with the existing application, and how will moving to a web application fix that?  120K lines of code is significant.  If you already have developers trained in the technologies you are already using, and it's working well, why would you change?  Without answering that question, any evaluation of potential solutions is meaningless.  I'm guessing that reliability and speed are two concerns?

You use the term "LAMP stack" loosely.  I have always picked technologies that are cross-platform, instead of ones that lock you into a single vendor.  Open-source is good if the license fits the way you plan to use it.

It sounds like you have a wealth of Microsoft-specific knowledge at your organization, so you may not want to pay the price of retraining.

As @Wyatt Barnett said, once an application is developed, if the technology you use is appropriate to the task, the cost of maintaining it is not related to the brand-name of that technology.

As far as appropriate goes, 120K lines of code would be a nightmare to manage in PHP, and might be slow in Ruby.  Pick something popular so you can find developers as you need them.  I'd go with Java or C#/.Net.  A lot of people are using Spring with Java these days.


答:
In reference to gbjbaanb's comment, some of the things that make game programming fun is the limited lifespan of the code base and the lack of requiring precisions. For example, if you're designing an FPS game, and your movement algorithm sometimes places your game character a few pixels off, it's no big deal and chances are no one will notice. If you're designing a piece of business software and occasionally your sum function places you a few dollars off, that's a much more serious bug. So when designing games some aspects can be much less precise (and only have to pass human testing, rather than an automated test suite which checks that the answers are precisely correct).

My experience has been that game programming, especially for real-time games, is a much different experience from...almost any other software development I've done, maybe except for GUI work. It's something you have to try!

Title: What technologies are used for Game development now days?

Body:
Whenever I ask a question about game development in an online forum I always get suggestions like learning line drawing algorithms, bit level image manipulation and video decompression etc.

However looking at games like God of War 3, I find it hard to believe that these games could be developed using such low level techniques.

The sheer awesomeness of such games defy any comprehensible(for me) programming methodology.

Besides the gaming hardware is really a monster now days. So it stands to reason that the developers would work at a higher level of abstraction.

What is the latest development methodology in the gaming industry? How is it that a team of 30-35 developers (of which most is management and marketing fluff) able to make such mind boggling games?

If the question seems too general could you explain the architecture of God of War 3? Or how you would go about producing a clone? That I think should be objectively answerable.


问:
Code Design question, circular reference across classes?
I have no code here, as this is more of a design question (I assume this is still the best place to ask it).

I have a very simple server in java which stores a mapping between certain values and UUID which are to be used by many systems across multiple platforms.  It accepts a connection from a client and creates a clientSocket which stores the socket and all the other relevant data unique to that connection.  Each clientSocket will run in their own thread and will block on the socket waiting for a read.  I expect very little strain on this system, it will rarely get called, but when it does get a call it will need to respond quickly and due to the risk of it having a peak time with multiple calls coming in at once threaded is still better.

Each thread has a reference to a Mapper class which stores the mapping of UUID which it's reporting to others (with proper synchronization of course).  This all works until I have to add a new UUID to the list.  When this happens I want to report to all clients that care about that particular UUID that a new one was added.  I can't multicast (limitation of the system I'm running on) so I'm having each socket send the message to the client through the established socket.  However, since each thread only knows about the socket it's waiting on I didn't have a clear method of looking up every thread/socket that cares about the data to inform them of the new UUID.

Polling is out mostly because it seems a little too convoluted to try to maintain a list of newly added UUID.  My solution as of now is to have the 'parent' class which creates the mapper class and spawns all the threads pass itself as an argument to the mapper.  Then when the mapper creates a new UUID it can make a call to the parent class telling it to send out updates to all the other sockets that care about the change.

I'm concerned that this may be a bad design due to the use of a circular reference; parent has a reference to mapper (to pass it to new ClientSocket threads) and mapper points to parent.  It doesn't really feel like a bad design to me but I wanted to check since circular references are suppose to be bad.

Note: I realize this means that the thread associated with whatever socket originally received the request that spawned the creation of a UUID is going to pay the 'cost' of outputting to all the other clients that care about the new UUID. I don't care about this; as I said I suspect the client to receive only intermittent messages.  It's unlikely for one socket to receive multiple messages at one time, and there won't be that many sockets so it shouldn't take too long to send messages to each of them.  Perhaps later I'll fix the fact that I'm saddling higher work load on whatever unfortunate thread gets the first request; but for now I think it's fine.

答:
A general way these references are broken is via interfaces.  Instead of the parent class having a reference to the mapper, have it hold a reference to IWhateverParentNeedsFromMapper.  Instead of the mapper having a reference to the parent, have it hold a reference to IWhateverMapperNeedsFromParent.

Often, thinking about the problem in this way ends up with a nice descriptive interface name, and a small set of operations within it.

You don't break the "real" circular reference, but instead that reference is an implementation detail instead of a hard requirement of your class design.

As a side note, this:

I wanted to check since circular references are suppose to be bad

Don't think like that. :)  There are lots and lots of things that are supposed to be bad powering everything you use every day.  Working code trumps "theoretically better" code under most circumstances.

OwnerDisplayName: dsollen


答:
Let's pretend you are copying a data structure from one file to another, and you use a buffer to store the data between the time you read it and the time you write it.

There is an overhead when you read and write data.  On disk, the head has to find the sector and read or write the track.  In memory, it takes a processor instruction to move a chunk of memory (usually 1-8 bytes at a time) plus a bus operation to move data from one part of memory to another, or between memory and the processor or memory and disk.  Each chunk that you read is processed in a loop somewhere and the smaller the chunks, the more times the loop has to be executed.

If your buffer is a single byte, you will incur this overhead every time you read or write a byte of data.  In our example, the disk can't read and write simultaneously, so the write may have to wait until the read is finished.  For a one-byte file, this is the best you can do, but for a 1MB file, this will be extremely slow.

If you have a 10MB buffer and want to copy a 10MB file, you can read the whole thing into your buffer, then write it all out again in one step.

Now, if you want to copy a 20GB file, you probably don't have that much memory.  Even if you do, if every program allocated 20GB of memory for buffers, there wouldn't be anything left!  When you allocate memory, you have to release it, and both the allocation and release can take time.

If a client of some kind is waiting for whole chunks of data, sometimes smaller chunks are better.  If the client gets a few chunks and knows they don't want the rest, they can abort, or maybe they can display what they have while waiting for more so that a human user can see that something is going on.

If you know the amount of data you are copying before you have to allocate your buffer, you can make a buffer that's the ideal size for the data you are copying.  Either the exact size of all your data, or big enough for the data to be copied in a reasonable number of chunks.  If you have to guess, some size around 1MB is reasonable for an unknown purpose.

To create the perfect sized buffer, you need to study the data that you are going to use it for.  If you are copying files, how big are most of the files people copy?  Then you guess at a good buffer size and time it.  Tweak the size and time it again.  Your total available memory may limit your maximum size.  Eventually you arrive at the ideal buffer size for your specific goal.

Title: Is using a bigger buffer useful?


答:
Disclaimer: I am not a video game developer. But I do have a "hobbyist" interest in it.

Most of the AAA games you see are made using Engines. They aren't written from the ground up. Think of an engine like a framework. You have .NET framework, Java SDK, Cocoa toolkit.

All things to make your job of creating software easier and abstracting away the kitchen-sink code. It's necessary, but writing it every time is very unproductive.

Using these engines developer can build their game and not have to worry about some of the underlying code. (Make no mistake, game development is one of the hardest branches of software engineering.)

For example, Unreal Engine 4 has a killer development kit and studio:

http://www.youtube.com/watch?v=MOvfn1p92_8

There are many different engines out there. Some paid, some free, some more down to the metal, others offer a higher abstraction.

For example:

OGRE

Unreal Engine

Unity

Source

and many more...


答:
ID Software is one of the vendors which usually publishes state of the art games. A few years later they often release those as open source. On http://fabiensanglard.net/quake3/index.php you can find an analysis of the Quake3 source code. This is a quite verbose description and even though Quake3 is quite old meanwhile the concepts there should still be relevant for modern games.

And yes, if you want to build a state-of-the-art modern fast, competitive game engine you will have to know all those low-level pieces. If you don't want to care about those: There are different engines (quake3 engine or the ones from other answers) available but well, then you're not creating a new revolutionary game ;-)


问:
How do PGP and PEM differ?
Email messages are sent in plain text which means that the messages I send to Derpina are visible to anyone who somehow gets access to them while they are in transit.

To overcome this, various encryption mechanisms were developed: PEM and PGP are two of them.

PEM canonically converts, adds digital signature, encrypts, and sends; PGP does exactly the same.

So how do they differ? Is it that PGP (being a program) is used to generate a PEM message?

答:
PEM was a proposed IETF standard for secure email. It depended on a single root certificate for its public key infrastructure (PKI), which was impractical and had its own problematic implications for security.

PGP started as a "proof of concept" for a less centralized "web of trust" PKI, and proved to be much more practical, finding widespread adoption and eventually founding the OpenPGP standard, while PEM faded into obscurity.

So basically PEM and PGP were competing protocols for encrypting emails, and PGP "won" while PEM "lost".

Title: How do PGP and PEM differ?


答:
It all depends on what you are doing and with what machinery and so forth.  Try different numbers and see what happens.

However, I have found that the bigger the buffer, the faster the reads and writes.  I mention this because you talk about 1024 and 2048.  Try some really big buffers instead.  I found in one case I was reading 8 times as fast by switching from 8Kb up to 100Kb, and I got noticable improvements up to 1Mb.

I'm no hardware expert, but I've found generally computers do sequential byte copies at many times the speed of an individual byte copy.  Maybe they do things in parallel, maybe it moves data through caches faster, maybe it's magic.  But using big buffers and array copies (or loops that optimizers can turn into array copies) can save a lot of time.

Title: Is using a bigger buffer useful?


答:
Well, I think the real issue is that you want your installation document to be kept up-to-date. That is nothing you can really solve by improving the design of the document. Someone has to be responsible for this, for example, the developers of the system whenever they change something which influences the installation.

Of course, the chances that someone takes care of this are much higher when the installation description is very small, so what @kevincline wrote in his comment is a step in the right direction: create scripts or installer procedures requiring as few user interaction as possible. A simple "readme" file should be enough - ideally, you don't need any installation description, because you just start your "setup" script which does all the right things.

However, if you move installation description into installation scripts, then still those scripts have to be kept up-to-date, which in fact only shifts the problem from one media to another. Someone has actually to test those installation scripts on a regular basis, and fix issues as soon as they occur. Of course, having just one installation script for a program has the advantage that the installation can be tested with much less manual effort.

Title: How to correctly write an installation or setup document

Body:
I just joined a small start-up as a software engineer after graduation. The start-up is 4 year old, and I am working with the CEO and the COO, even if there are some people abroad. Basically they both used to do almost everything. I am currently on some kind of training phase. I have at my disposition architecture, setup and installation internal documentation. Architecture documentation is like a bible and should contain complete information. The rest are used to give directions in different processes.

The issue is that these documents are more or less dated, as they just didn't have the time to change them. I will be in charge of training the next hires, and updating these documents is part of my training. In some there is a lot of hard-coded information like:

```<code> Install this_module_which_still_exists
     cd this_dir_name_changed
     cp this_file_name_changed other_dir_name_changed
     ./config_script.sh
     ./execute_script.sh
</code>```

The issues i have faced :

Either the module installation is completely different (for instance now there is an rpm, or a different OS)

Either names changed, and i need to switch old names by new names

Description of the purpose of the current step missing.

Information about a whole topic is missing

Fortunately these guys are around and I get all the information I want and all the explanations I need. I want to bring a design to the next documents so in the future people don't feel like they are completely rewriting a document each time they are updating it.

Do you have suggestions?
If there is a lightweight design methodology available online you can point me to it's nice too.

One thing I will do for sure is set up a versioning repository for the documents alone. There is already one for the source code so I don't know why internal documents deserve a different treatment.


答:
As many answers mention, game engines and libraries play a big part. However, do note that this applies to mid-big commercial games more than to small "indie" games.

For example on mobile platforms most games are written using only a set of relatively primitive libraries rather than relying on full-blown game-engines an frameworks. They do exist, but for the most part it's about re-using your own code from earlier projects.


问:
MVC, when to separate controllers?
I'm starting with MVC and have a newbie question.  What would be the logic criteria to define what a controller should encompass?  For example, say a website has a 'help' section. In there, there are several options like: 'about us', 'return instructions', 'contact us', 'employment opportunities'.  Each would then be accessed like 'mysite.com/help/aboutus', 'mysite.com/help/returns', 'mysite.com/help/contactus', etc.

My question is, should I have a 'help' controller that has 'about us', 'returns', 'contact us', 'employment' as actions with their respective view, or should each of those be a different controller-action-view set?  What should be the line of reasoning to determine when to separate controllers?

答:
That is entirely up to you.

With ASP.Net MVC3 you can choose if you want the default routing to do the work, or if you want to manually create some sexy URLs. You can create routes that look to be within the same controller but they can in fact be in many different controllers.

The criteria you should use when deciding the organization of Controllers and their method is, are these actions related in some way?

Following your example for Help. It would make sense to keep them within the same controller because they do offer "Help" in one way or another.

Title: MVC, when to separate controllers?


问:
Overloading interface buttons, what are the best practices?
Imagine you'll have always a button labeled "Continue" in the same position in your app's GUI.
Would you rather make a single button instance that takes different actions depending on the current state?

```<code>private State currentState = State.Step1;

private ContinueButton_Click()
{
    switch(currentState)
    {
        case State.Step1:
            DoThis();
            currentState = State.Step2;
            break;
        case State.Step2:
            DoThat();
            break;
    }
}
</code>```

Or would you rather have something like this?

```<code>public Form()
{
    this.ContinueStep2Button.Visible = false;
}

private ContinueStep1Button_Click()
{
    DoThis();
    this.ContinueStep1Button.Visible = false;
    this.ContinueStep2Button.Visible = true;
}

private ContinueStep2Button_Click()
{
    DoThat();
}
</code>```

答:
My proposal is to have a single button, but instead of the switch statement, have a listener interface which is implemented by classes that processes the clicks, and on every click, change the listener that is now responsible.</p>

```<code>class myForm extends Form {
   ClickListener listener1 = new ClickListener_page1(this);

   private Continuebutton1_Click() {
       listener1.click();
   }
}

class ClickListener_page1 implements ClickListener {
    Form form;

    public ClickListener_page1(Form form) {
       this.form = form;
    }

    public click() {
        page++;
        // here goes all the stuff to process page 1
        form.listener1 = new ClickListener_page2(form);
    }
}

class ClickListener_page2 implements ClickListener {
    Form form;

    public ClickListener_page2(Form form) {
       this.form = form;
    }

    public click() {
        page++;
        // here goes all the stuff to process page 2
        form.listener1 = new ClickListener_page2(form);
    }
}
</code>```

Body:
My proposal is to have a single button, but instead of the switch statement, have a listener interface which is implemented by classes that processes the clicks, and on every click, change the listener that is now responsible.

class myForm extends Form {
   ClickListener listener1 = new ClickListener_page1(this);

   private Continuebutton1_Click() {
       listener1.click();
   }
}

class ClickListener_page1 implements ClickListener {
    Form form;

    public ClickListener_page1(Form form) {
       this.form = form;
    }

    public click() {
        page++;
        // here goes all the stuff to process page 1
        form.listener1 = new ClickListener_page2(form);
    }
}

class ClickListener_page2 implements ClickListener {
    Form form;

    public ClickListener_page2(Form form) {
       this.form = form;
    }

    public click() {
        page++;
        // here goes all the stuff to process page 2
        form.listener1 = new ClickListener_page2(form);
    }
}


问:
software architecture (OO design) refresher course
I am lead developer and team lead in a small RAD team. Deadlines are tight and we have to release often, which we do, and this is what keep the business happy.

While we (the development team) are trying to maintain the quality of the code (clean and short methods), I can't help but notice that the overall quality of the OO design&architecture is getting worse over the time - the library we are working on is gradually reducing itself to a "bag of functions". Well, we try to use the design patterns, but since we don't really have much time for a design as such we are mostly using the creational ones.

I have read Code Complete / Design Patterns (GOF & enterprise) / Progmatic Programmer / and many books from Effective XXX series. Should I re-read them again as I have read them a long time ago and forgotten quite a lot, or there are other / better OO design / software architeture books been published since then which I should definitely read?

Any ideas, recommendations on how can I get the situation under control and start improving the architecture. The way I see it - I will start improving the architectural / design quality of software components I am working on and then will start helping other team members once I find what is working for me.

答:
I can detect something from your question:

You seem to think that "improving" software architecture is possible. This is not true. Every modification you're doing can only break the original design idea - the ideas you had years ago were already forgotten and something else replaced them.

What you can do is "try to follow existing architecture." This takes effort to understand and follow it. Should only do such improvements which follow the existing architecture. The architecture gets stronger once people stop inventing new stuff and just follow the existing patterns.

Over time software is going to get more complicated. This can hide the original structure of the software if the new stuff is inventing new patterns.


问:
Scrum: How to work on one story at a time
I was nominated as scrum master in a new formed scrum team. We have already done some sprints. In the beginning I tried to make my team to work on one story at a time. But it didn't work.
My team had difficulties to distribute the tasks in a way that they can work simultaneously on one story. Maybe we are doing something wrong?

For example: we have a story to create a new dialog. We create the following tasks:

Create Model classes

Read model data from database

Connect model classes with view

Implement dialog handling

Save data on close

Test Documentation

Solution Description

Can theses tasks be done by more than one person at a time? The tasks - more or less - build upon each other.
Or do we design the tasks in a wrong way?

答:
Your tasks, as indicated, seem 'small' enough to be distributed, but there is some coupling between tasks such as the one about modeling the data and retrieving it from the database.

What would be possible is to split it up into three main things people can work on concurrently, with some extra work/setup:

Back-end (database, model etc)

Front-end (using mock data)

Tests (setting up expectations, scenario, etc)

Tasks that cannot be split can be done by pairs. And of course, there's nothing inherently wrong with more than one story being in progress at any one point; just as long as every member of the team knows what the others are doing, and they can help out whenever needed (as in, 'shared code ownership').

You should keep your team focused, yes, but at the same time you need to keep everyone busy, and everyone involved.

Also, how big is your team? This is also a factor; it's pretty hard to have ten people work on one story, and if you can, your story is far, far too big and should be split up (as should your team).


答:
Another approach for an refreshment is Clean Coders. It's a collection of videos from Uncle Bob (Robert C. Martin).

Look at the headlines of these videos. You will see that they are mostly about TDD, Clean Code, SOLID and Component Patterns. Our team is watching one video per week (with a discussion afterwards) to have a common understanding what principles we want to follow. Unit testing for example... and the videos explaining very good, how to do it and how to start.

Title: software architecture (OO design) refresher course

Body:
I am lead developer and team lead in a small RAD team. Deadlines are tight and we have to release often, which we do, and this is what keep the business happy.

While we (the development team) are trying to maintain the quality of the code (clean and short methods), I can't help but notice that the overall quality of the OO design&architecture is getting worse over the time - the library we are working on is gradually reducing itself to a "bag of functions". Well, we try to use the design patterns, but since we don't really have much time for a design as such we are mostly using the creational ones.

I have read Code Complete / Design Patterns (GOF & enterprise) / Progmatic Programmer / and many books from Effective XXX series. Should I re-read them again as I have read them a long time ago and forgotten quite a lot, or there are other / better OO design / software architeture books been published since then which I should definitely read?

Any ideas, recommendations on how can I get the situation under control and start improving the architecture. The way I see it - I will start improving the architectural / design quality of software components I am working on and then will start helping other team members once I find what is working for me.


答: Typically a controller maps a class to a base URL, usually a webpage e.g. mysite.com/help, so you have the right idea. The class methods are typically handlers for actions triggered by controls on the page - which typically have an appended path e.g. mysite.com/help/contact - if say 'contact' were a button that opened the user's default mail program w/ the company's address populated in the 'To' field.</p>

Title: MVC, when to separate controllers?

Body:
I'm starting with MVC and have a newbie question.  What would be the logic criteria to define what a controller should encompass?  For example, say a website has a 'help' section. In there, there are several options like: 'about us', 'return instructions', 'contact us', 'employment opportunities'.  Each would then be accessed like 'mysite.com/help/aboutus', 'mysite.com/help/returns', 'mysite.com/help/contactus', etc.

My question is, should I have a 'help' controller that has 'about us', 'returns', 'contact us', 'employment' as actions with their respective view, or should each of those be a different controller-action-view set?  What should be the line of reasoning to determine when to separate controllers?


问:
Name for this antipattern? Fields as local variables
In some code I'm reviewing, I'm seeing stuff that's the moral equivalent of the following:

```<code>public class Foo
{
    private Bar bar;

    public MethodA()
    {
        bar = new Bar();
        bar.A();
        bar = null;
    }

    public MethodB()
    {
        bar = new Bar();
        bar.B();
        bar = null;
    }
}
</code>```

The field bar here is logically a local variable, as its value is never intended to persist across method calls. However, since many of the methods in Foo need an object of type Bar, the original code author has just made a field of type Bar.

This is obviously bad, right?

Is there a name for this antipattern?

答:
I've encountered this many times, usually when refreshing code previously written by someone who picked up VBA For Dummies as their first title and went on to write a relatively large system in whatever language they'd stumbled into.

To say it's really bad programming practice is right, but it might just have been a result of not having internet & peer reviewed resources such as we all enjoy today that might have guided the original developer along a "safer" path.

It doesn't really deserve the "antipattern" tag though - but it's been good to see the suggestions of how the OP could be recoded.


答: It isn't a bad design. Back pointers are a commonly used mechanism. There's already a dependency between the classes, so you're not creating a coupling where none existing. You could make it an abstract coupling by introducing interfaces, IF you choose to, but that violates YAGNI. Incidentally, note that the java import statement supports circular dependencies and Spring setter injection enables circular dependencies by supporting two stage construction.</p>

Title: Code Design question, circular reference across classes?

Body:
I have no code here, as this is more of a design question (I assume this is still the best place to ask it).

I have a very simple server in java which stores a mapping between certain values and UUID which are to be used by many systems across multiple platforms.  It accepts a connection from a client and creates a clientSocket which stores the socket and all the other relevant data unique to that connection.  Each clientSocket will run in their own thread and will block on the socket waiting for a read.  I expect very little strain on this system, it will rarely get called, but when it does get a call it will need to respond quickly and due to the risk of it having a peak time with multiple calls coming in at once threaded is still better.

Each thread has a reference to a Mapper class which stores the mapping of UUID which it's reporting to others (with proper synchronization of course).  This all works until I have to add a new UUID to the list.  When this happens I want to report to all clients that care about that particular UUID that a new one was added.  I can't multicast (limitation of the system I'm running on) so I'm having each socket send the message to the client through the established socket.  However, since each thread only knows about the socket it's waiting on I didn't have a clear method of looking up every thread/socket that cares about the data to inform them of the new UUID.

Polling is out mostly because it seems a little too convoluted to try to maintain a list of newly added UUID.  My solution as of now is to have the 'parent' class which creates the mapper class and spawns all the threads pass itself as an argument to the mapper.  Then when the mapper creates a new UUID it can make a call to the parent class telling it to send out updates to all the other sockets that care about the change.

I'm concerned that this may be a bad design due to the use of a circular reference; parent has a reference to mapper (to pass it to new ClientSocket threads) and mapper points to parent.  It doesn't really feel like a bad design to me but I wanted to check since circular references are suppose to be bad.

Note: I realize this means that the thread associated with whatever socket originally received the request that spawned the creation of a UUID is going to pay the 'cost' of outputting to all the other clients that care about the new UUID. I don't care about this; as I said I suspect the client to receive only intermittent messages.  It's unlikely for one socket to receive multiple messages at one time, and there won't be that many sockets so it shouldn't take too long to send messages to each of them.  Perhaps later I'll fix the fact that I'm saddling higher work load on whatever unfortunate thread gets the first request; but for now I think it's fine.


问:
Have javac call automatically run java
I want to be able to call javac <class file name>, and then automatically run java on the compiled .class file.

I thought initially to use a x86 disassembler to hack it (javac.exe) but bumped that idea; I then found the open source code for JDK, and concluded that maybe a batch file would be easier. How can I do this?

答:
It would probably be easier to use a build tool, like Ant. You could have a target to compile, a target to run your tests, a target to run, and so forth. You can set up different dependencies between them (for example, always make test clean your build files and compile before running).

Alternatively, a shell script would be the next best bet. However, that would be far less portable than something like Ant.

Title: Have javac call automatically run java


答:
Unity3D is really nice. Here's some points I like about it:

it lets you build games in a platform agnostic fashion, and then automatically creates deployables for either Windows, Mac OS X, Android, IOS. This is true for the current version (3.x). Apparentlly version 4 will let you deploy on Linux as well:

http://en.wikipedia.org/wiki/Unity_(game_engine)#Major_features

Even though you need a payed license to actually use it (commercially), you can donwload a free version in which you can use most of the features (i.e. you cannot for example make deployables for the mobile platforms). It gives a great way to preview the thing before you decide to buy it or not:

http://unity3d.com/unity/licenses

Works with most 3d modelling software (I prefer 3d Studio Max, but it supports others as well):

http://unity3d.com/unity/editor/importing (scroll down a bit)

Coding (scripting) can be done in C# which is a nice language, with a good API and compile time checks. Comes with a good dev environment (IDE and everything). If you want something different, it supports Javascript as well.

Has very good physics support (collisions, gravity, forces, etc):

http://docs.unity3d.com/Documentation/Manual/Physics.html

Has an asset store that lets you buy various models, scripts, animations etc, and depending on your skill (and wallet) you can get/modify those to quickly obtain decent resources for your game.

Last but not least, it's decently fast. Check out the mobile demos, IMHO they move quite well and have very decent graphics:

http://unity3d.com/gallery/made-with-unity/game-list

Here's one nice Unity project I'm currently waiting for:

Brian Fargo's Wasteland 2

They have a nice blog entry about why they chose Unity, as well as other discussing how working with it goes along.


答:
Do you want to run this as a process from within another Java process or from the Shell ?

If its from within a Java process,take a look at the Processbuilder API

Title: Have javac call automatically run java

Body:
I want to be able to call javac <class file name>, and then automatically run java on the compiled .class file.

I thought initially to use a x86 disassembler to hack it (javac.exe) but bumped that idea; I then found the open source code for JDK, and concluded that maybe a batch file would be easier. How can I do this?


问:
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?

答:
Suppose you have a lot of expensive calculations on offer, but don't know which ones will actually be needed, or in which order.  You could add a complicated mother-may-i protocol
to force the consumer to figure out what's available and trigger calculations that are not yet done.  Or you could just provide an interface that acts as though the calculations were
all done.

Also, suppose you have an infinite result. The set of all primes for example.  It's obvious that you can't calculate the set in advance, so any operation in the domain of primes has to be lazy.


问:
How do you encode Algebraic Data Types in a C#- or Java-like language?
There are some problems which are easily solved by Algebraic Data Types, for example a List type can be very succinctly expressed as:

```<code>data ConsList a = Empty | ConsCell a (ConsList a)

consmap f Empty          = Empty
consmap f (ConsCell a b) = ConsCell (f a) (consmap f b)

l = ConsCell 1 (ConsCell 2 (ConsCell 3 Empty))
consmap (+1) l
</code>```

This particular example is in Haskell, but it would be similar in other languages with native support for Algebraic Data Types.

It turns out that there is an obvious mapping to OO-style subtyping: the datatype becomes an abstract base class and every data constructor becomes a concrete subclass. Here's an example in Scala:

```<code>sealed abstract class ConsList[+T] {
  def map[U](f: T => U): ConsList[U]
}

object Empty extends ConsList[Nothing] {
  override def map[U](f: Nothing => U) = this
}

final class ConsCell[T](first: T, rest: ConsList[T]) extends ConsList[T] {
  override def map[U](f: T => U) = new ConsCell(f(first), rest.map(f))
}

val l = new ConsCell(1, new ConsCell(2, new ConsCell(3, Empty)))
l.map(1+)
</code>```

The only thing needed beyond naive subclassing is a way to seal classes, i.e. a way to make it impossible to add subclasses to a hierarchy.

How would you approach this problem in a language like C# or Java? The two stumbling blocks I found when trying to use Algebraic Data Types in C# were:

I couldn't figure out what the bottom type is called in C# (i.e. I couldn't figure out what to put into class Empty : ConsList< ??? >)

I couldn't figure out a way to seal ConsList so that no subclasses can be added to the hierarchy

What would be the most idiomatic way to implement Algebraic Data Types in C# and/or Java? Or, if it isn't possible, what would be the idiomatic replacement?

答:
There is an easy, but boilerplate heavy way to seal classes in Java.  You put a private constructor in the base class then make subclasses inner classes of it.

```<code>public abstract class List<A> {

   // private constructor is uncallable by any sublclasses except inner classes
   private List() {
   }

   public static final class Nil<A> extends List<A> {
   }

   public static final class Cons<A> extends List<A> {
      public final A head;
      public final List<A> tail;

      public Cons(A head, List<A> tail) {
         this.head = head;
         this.tail = tail;
      }
   }
}
</code>```

Tack on a visitor pattern for dispatch.

My project jADT : Java Algebraic DataTypes generates all that boilerplate for you https://github.com/JamesIry/jADT

ContentLicense: CC BY-SA 4.0

Body:
There is an easy, but boilerplate heavy way to seal classes in Java.  You put a private constructor in the base class then make subclasses inner classes of it.

public abstract class List<A> {

   // private constructor is uncallable by any sublclasses except inner classes
   private List() {
   }

   public static final class Nil<A> extends List<A> {
   }

   public static final class Cons<A> extends List<A> {
      public final A head;
      public final List<A> tail;

      public Cons(A head, List<A> tail) {
         this.head = head;
         this.tail = tail;
      }
   }
}

Tack on a visitor pattern for dispatch.

My project jADT : Java Algebraic DataTypes generates all that boilerplate for you https://github.com/JamesIry/jADT


答:
If you are familiar with databases, a very frequent way to process data is:

Ask a question like select * from foobar

While there is more data, do: get next row of results and process it

You do not control how the result is generated and in which way (indexes?  Full table scans?), or when (should all the data be generated at once or incrementally when being asked for?).  All you know is: if there is more data, you will get it when you ask for it.

Lazy evaluation is pretty close to the same thing. Say you have an infinite list defined as ie. the Fibonacci sequence - if you need five numbers, you get five numbers calculated; if you need 1000 you get 1000. The trick is that the runtime knows what to provide where and when. It is very, very handy.

(Java programmers can emulate this behavior with Iterators - other languages may have something similar)

Title: Why is the concept of lazy evaluation useful?

Body:
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?


答:
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?

When an expression is side-effect free, the order in which the expressions are evaluated does not affect their value, so the behavior of the program is not affected by the order. So the behavior is perfectly predictable.

Now side effects are a different matter. If side effects could occur in any order, the behavior of the program would indeed be unpredictable. But this is not actually the case. Lazy languages like Haskell make it a point to be referentially transparent, i.e. making sure that the order in which expressions are evaluated will never affect their result. In Haskell this is achieved by forcing all operations with user-visible side effects to occur inside the IO monad. This makes sure that all side-effects occur exactly in the order you'd expect.


问:
What are the fundamental differences between C and C++?
Many tend to write "C/C++", as if they were the same thing. Although they share many similarities, they are clearly not the same.

But what are really the fundamental differences between C and C++? Is C++ an enhanced version of C, or are there features in C which do not exist in C++?

答:
C++ was invented to manage complexity that C could not handle.
For example, a common problem with C was that you could "run out of names for variables" (not to be taken literally of course) because there was no encapsulation, namespaces etc.

Also, C does not have exceptions, therefore error handling is very error prone, since it depends on the library user to always check return values of functions, whereas with exceptions, the library developer simply throws an exception that guarantees program flow will be halted.

C++ helps by having the constructor init objects which is automatically called by compiler. Unlike C structs which need to be initialized by the programmer (hence another error-prone area).

Lastly, there is a lot of other advantages touted by OOP, such as object reuse as well the generic programming based concepts, such as templates and generics which allow you to reuse source code,etc.

ContentLicense: CC BY-SA 2.5


答:
Consider asking your database for a list of the first 2000 users whose names start with "Ab" and are older than 20 years. Also they must be male.

Here's a little diagram.

```<code>You                                            Program Processor
------------------------------------------------------------------------------
Get the first 2000 users ---------->---------- OK!
                         --------------------- So I'll go get those records...
WAIT! Also, they have to ---------->---------- Gotcha!
start with "Ab"
                         --------------------- NOW I'll get them...
WAIT! Make sure they're  ---------->---------- Good idea Boss!
over 20!
                         --------------------- Let's go then...
And one more thing! Make ---------->---------- Anything else? Ugh!
sure they're male!

No that is all. :(       ---------->---------- FINE! Getting records!

                         --------------------- Here you go.
Thanks Postgres, you're  ---------->----------  ...
my only friend.
</code>```

As you can see by this terrible terrible interaction, the "database" isn't actually doing anything until it's ready to handle all the conditions. It's lazy-loading results at each step and applying new conditions each time.

As opposed to getting the first 2000 users, returning them, filtering them for "Ab", returning them, filtering them for over 20, returning them, and filtering for male and finally returning them.

Lazy loading in a nutshell.

Body:
Consider asking your database for a list of the first 2000 users whose names start with "Ab" and are older than 20 years. Also they must be male.

Here's a little diagram.

You                                            Program Processor
------------------------------------------------------------------------------
Get the first 2000 users ---------->---------- OK!
                         --------------------- So I'll go get those records...
WAIT! Also, they have to ---------->---------- Gotcha!
start with "Ab"
                         --------------------- NOW I'll get them...
WAIT! Make sure they're  ---------->---------- Good idea Boss!
over 20!
                         --------------------- Let's go then...
And one more thing! Make ---------->---------- Anything else? Ugh!
sure they're male!

No that is all. :(       ---------->---------- FINE! Getting records!

                         --------------------- Here you go.
Thanks Postgres, you're  ---------->----------  ...
my only friend.

As you can see by this terrible terrible interaction, the "database" isn't actually doing anything until it's ready to handle all the conditions. It's lazy-loading results at each step and applying new conditions each time.

As opposed to getting the first 2000 users, returning them, filtering them for "Ab", returning them, filtering them for over 20, returning them, and filtering for male and finally returning them.

Lazy loading in a nutshell.


答:
Lazy evaluation of expressions will cause the designer of a given
  piece of code lose control over the sequence their code is executed.

The designer shouldn't care about the order in which expressions are evaluated provided the result is the same. By deferring evaluation, it may be possible to avoid evaluating some expressions altogether, which saves time.

You can see the same idea at work at a lower level: many microprocessors are able to execute instructions out of order, which lets them use their various execution units more efficiently. The key is that they look at dependencies between instructions and avoid reordering where it would change the result.


答:
I've stumbled upon this in the past. I had a button changing its label (from Next to Finish) but otherwise keeping its position. I used two distinct buttons.

In general, I prefer using different physical buttons and playing with their visibility, instead of using a single button and changing its behavior. The rationale is simply that the former is easier to understand and maintain. Imagine expanding your problem to multiple buttons which can have different behaviors in different contexts and having to change the listeners on those buttons when the context changes. This can push you into an artificial pattern of having to save references to, or re-instantiate your button listeners, or devise artificial click handling schemes.

That said, in some cases the logical model dictates the use of an action with contextual results, such as "Save". If that action is prominently displayed in a global area, such as a header, such as it is always visible, then I believe it makes sense for that action to remain shared. Of course, in such a case, the action delegates to the screen currently displayed in order to achieve the action, so, again, logic dictates your outcome.

If there is a different logical action, different listeners, little relationship between the actions, these are strong indicators of the need to use different buttons and adjust their visibility based on context.

If, on the other hand, the actions have a common pattern (as supported by the button label - probably your case), then use a single button and investigate the possibility of delegation to the current context to achieve the action.

[It's interesting to think about, in the latter case, dealing with common pattern actions where some require more user input (actions that should have an ellipsis (...)), and some do not, in which case it becomes tricky to use the same button.]

Title: Overloading interface buttons, what are the best practices?

Body:
Imagine you'll have always a button labeled "Continue" in the same position in your app's GUI.
Would you rather make a single button instance that takes different actions depending on the current state?

```<code>private State currentState = State.Step1;

private ContinueButton_Click()
{
    switch(currentState)
    {
        case State.Step1:
            DoThis();
            currentState = State.Step2;
            break;
        case State.Step2:
            DoThat();
            break;
    }
}
</code>```

Or would you rather have something like this?

```<code>public Form()
{
    this.ContinueStep2Button.Visible = false;
}

private ContinueStep1Button_Click()
{
    DoThis();
    this.ContinueStep1Button.Visible = false;
    this.ContinueStep2Button.Visible = true;
}

private ContinueStep2Button_Click()
{
    DoThat();
}
</code>```


问:
Do I need to know servlets and JSP to learn spring or hibernate or any other java web frameworks?
I've been asking a lot of people where to start learning java web development, I already know core java (Threading,Generics,Collections, a little experience with (JDBC)) but I do not know JSPs and servlets. I did my fair share of  development with several web based applications using PHP for server-side and  HTML,CSS,Javascript,HTML5 for client side.

Most people that I asked told me to jump right ahead to Hibernate while some told me that I do not need to learn servlets and jsps and I should immediately study the Spring framework. Is this true? do I not need to learn servlets and JSPs to learn hibernate or Spring?

All of their answers confused me and now I am completely lost what to learn or study. I feel that if I skipped learning JSP and servlets I would missed a lot of important concepts
that will surely help me in the future.

So the question, do I need to have foundation/know servlets and JSP to learn spring or hibernate or any other java web frameworks.?

答:
It sounds like you want to learn server side web development with java. There are a number of frameworks. Spring MVC is in fact the most popular, it is mature, very full-featured, and a good framework to know. Spring MVC and other java web frameworks abstract the java servlet API from the programmer - so technically you don't need to know it. But I would suggest learning the basics - particularly the key classes. A day of study should get you there.

As for JSP, if you know PHP you already understand the essentials. JSP is java's version of server-side scripting.

Hibernate is an implementation (the most popular) of JPA, which is the java spec for persisting objects to RDBMS. With the explosion in popularity of NOSQL db's (Hadoop, Mongo, etc), Hibernate is much less of a 'must know' than it was even 18 months ago. Personally I learn storage technologies on a need-to-know basis because there's a lot of them, and you lose what you don't use.


答:
If the operations are the same just on a different context (e.g. all are next or all are appply or all are send) you should use the same button.

If the operations are different (e.g. volume up vs. channel up or adjust equalizer) do not use the same button or position.


答:
I would suggest learning about basic JSP and Servlets as it will help you grasp the concepts that are simplified in Spring. Since you have experience with PHP-based CGIs, most of JSP/Servlets will just different ways of doing things you are familiar with so it should go fairly quickly. The hardest thing you may find will be picking up the unique idioms in the java world.

As far as Hibernate goes, I'll agree with MebAlone and say learn it if you need to, but if it's already set up you can do 90% of what you'll need to by just cribbing what others have done.

Title: Do I need to know servlets and JSP to learn spring or hibernate or any other java web frameworks?

Body:
I've been asking a lot of people where to start learning java web development, I already know core java (Threading,Generics,Collections, a little experience with (JDBC)) but I do not know JSPs and servlets. I did my fair share of  development with several web based applications using PHP for server-side and  HTML,CSS,Javascript,HTML5 for client side.

Most people that I asked told me to jump right ahead to Hibernate while some told me that I do not need to learn servlets and jsps and I should immediately study the Spring framework. Is this true? do I not need to learn servlets and JSPs to learn hibernate or Spring?

All of their answers confused me and now I am completely lost what to learn or study. I feel that if I skipped learning JSP and servlets I would missed a lot of important concepts
that will surely help me in the future.

So the question, do I need to have foundation/know servlets and JSP to learn spring or hibernate or any other java web frameworks.?


答:
Short answer: no, you don't need to learn Servlets and JSPs as a pre-requisite for Spring MVC and many other Java web frameworks.

Let's get Hibernate out of the picture first. It's a persistence layer framework and it doesn't have anything to do with Servlets and JSPs.

Servlet API is the lowest level for almost all Java web frameworks. Even JSPs are compiled to servlets.

Spring MVC is a layer on top of Servlet API with lots of helpful extensions and integration with Spring Core. You can use JSPs as a rendering mechanism for Spring MVC. Spring MVC tutorial will take you all the way from the ground up to create web apps. As you go along you will learn about JSPs, and you will be well equipped to understand Servlet API as well.


问:
Converting Fortran 77 code to C#
I'm trying to convert a Fortan77 program to C#. I have a subroutine with about 650 lines of code and horrific GOTO statements all over the place. I'm having a lot of trouble even starting to visualise the flow of the subroutine to figure out what it does.

Is there anybody with experience in this sort of thing who could give me any advice on how to get an overview of this subroutine? Are there some tools available to speed up or facilitate this type of conversion?

答:
Here is the way I actually went about translating the code into C#. Since .NET supports goto statements I first took the entire Fortran code and pasted it as is into a new method, well, as many methods as there were Fortran routines and subroutines.

The compiler came up with a million errors, mostly about undeclared variables and incorrect block statement formatting, which I cleared up one by one. I also had to rewrite some of the Fortran-specific code, like I/O statements and stuff like that. When that was done I had an exact replica of the original code.

Thanks to the nice formatting of Visual Studio the logical blocks were a lot easier to identify than in the original code. And I could start unravelling the goto statements one by one.

From this experience I have to say that there are some cases where goto statements are actually VERY useful to avoid having to rewrite the same code over and over again, although in a lot of cases the same can be achieved by using methods and calling those repeatedly.

I also used the free version of Silverfrost to compile the original code and perfrom regular checks on my reformatted code to ensure that the reformatting didn't produce errors.

Title: Converting Fortran 77 code to C#


答:
C99 has a few features that don't exist (at least in exactly the same form) in C++ (e.g., flexible array members, variable length arrays, etc.)

C99 also added a lot to the library that's not present in C++ 98/03 standard; most of this has been added to C++11 though.

In terms of basic orientation, C basically supports structured procedural programming. C++ supports that as well as object oriented programming, generic programming, and metaprogramming (carrying out arbitrary computation at compile time). With C++11, it adds a few bits and pieces that could at least be mistaken for functional programming support as well (e.g., lambda expressions). C++14 has added a few more, but most of them are really more convenience rather than any sort of major change in orientation.

Title: What are the fundamental differences between C and C++?

Body:
Many tend to write "C/C++", as if they were the same thing. Although they share many similarities, they are clearly not the same.

But what are really the fundamental differences between C and C++? Is C++ an enhanced version of C, or are there features in C which do not exist in C++?


问:
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).

答:
Having a code layer above the database is worthwhile in almost all cases. I would generally prefer a "GetByXXXXX" pattern in said code -- it lets you optimize queries behind it as needed while keeping the UI free of data interface clutter.

Taking advantage of generics is definitely fair game -- having a Load<T>(int id) method makes tons of sense. But building repositories around LINQ is the 2010s equivalent of dropping sql queries everywhere with a little added type safety.

OwnerDisplayName: Sam


答:
A lot of the answers are going into things like infinite lists and performance gains from unevaluated parts of the computation, but this is missing the larger motivation for laziness: modularity.

The classic argument is laid out in the much-cited paper "Why Functional Programming Matters" (PDF link) by John Hughes.  The key example in that paper (Section 5) is playing Tic-Tac-Toe using the alpha-beta search algorithm. The key point is (p. 9):

[Lazy evaluation] makes it practical to modularize a program as a generator that constructs a large number of possible answers, and a selector that chooses the appropriate one.

The Tic-Tac-Toe program can be written as a function that generates the whole game tree starting at a given position, and a separate function that consumes it.  At runtime this does not intrinsically generate the whole game tree, only those subparts that the consumer actually needs.  We can change the order and combination in which alternatives are produced by changing the consumer; no need to change the generator at all.

In an eager language, you can't write it this way because you would probably spend too much time and memory generating the tree.  So you end up either:

Combining the generation and consumption into the same function;

Writing a producer that works optimally only for certain consumers;

Implementing your own version of laziness.


答:
Well, with the link provided I can see that it may be a handy wrapper for a DataServiceContext, but does not reduce code manipulations nor improves readability. Besides, access to DataServiceQuery<T> is obstructed, limiting flexibility to .Where() and .Single(). Nor are AddRange() or alternatives provided. Nor is Delete(Predicate) provided which could be useful ( repo.Delete<Person>( p => p.Name=="Joe" ); to delete Joe-s). Etc.

Conclusion: such an API obstructs the native API and limits it to a few simple operations.

Title: Is There a Real Advantage to Generic Repository?

Body:
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).


答:
Failing anything else, you can use goto statements in C#.

The goto statement transfers the program control directly to a labeled statement.

A common use of goto is to transfer control to a specific switch-case label or the default label in a switch statement.

The goto statement is also useful to get out of deeply nested loops...

Title: Converting Fortran 77 code to C#

Body:
I'm trying to convert a Fortan77 program to C#. I have a subroutine with about 650 lines of code and horrific GOTO statements all over the place. I'm having a lot of trouble even starting to visualise the flow of the subroutine to figure out what it does.

Is there anybody with experience in this sort of thing who could give me any advice on how to get an overview of this subroutine? Are there some tools available to speed up or facilitate this type of conversion?


答:
If you've got a good grasp of HTML, CSS, and JavaScript, you have a leg up on many people who end up doing web development.  The concepts behind JSP are very similar to PHP.  The quirks are different.  A servlet is the name for a chunk of Java code that serves a request.  That's it really.  The whole original Struts framework was a single servlet.

I would add Tomcat or Jetty to your list of technologies to learn.  Tomcat is the original Java Servlet Container implementation and happens to also be a fully featured and rather popular web server.  GlassFish is built on top of it.  I've been using Jetty instead of Tomcat in my newer projects because it's simpler, more flexible, and faster.  Jetty was designed to make web services as opposed to web apps.  But a web app is just a web service that serves HTML in response to raw HTTP requests, so if you understand HTTP (which you can learn the important parts of in a few hours to a day), it's very easy to work with.

You can make a little web site with Tomcat and JSP (tutorial here or JSF) knowing just what you know and spending a few hours going through tutorials.  That way you can start where you are comfortable before stretching out.  Then make a javax.servlet.http.HttpServlet that writes "<title>Hi</title>
Hello World
" to the response object, list it in your Tomcat web.xml and send an HTTP request it from a web browser.  It's not rocket science.  All Java web frameworks are variations on those two basic activities.

If you go the Jetty route, it's even less structured.  Check out this Hello Jetty example.

If you're just going to make a blog or standard ecommerce site, I'd start with SquareSpace or Wordpress or something.  You get so much off the shelf, there's no way to justify custom coding any of that anymore.

The strength of Java for web applications is its reliability, maintainability, and performance.  PHP or Ruby/Rails is simpler, but Java will scale as much as you want to go.  I am not bowled over by any of the Java web frameworks.  When you have a team of people working on a large web application, or you need to use Hibernate, then a framework like Spring really shines.  Spring is the most popular.  When you have some familiarity with servlets and JSP/JSF, then learn how Spring ties those together with a data model.

If you are making a blog or a content management system, maybe you can get away with a NoSQL database.  But I would argue that NoSQL databases are basically just a caching layer on a file system, rather than replacing relational databases.  I think it's rare that a project that's a good fit for a NoSQL database is going to be appropriate to develop in Java.

Things that still require custom, high-performance code (in Java, PHP, whatever) are probably going to have a relational/SQL database powering them.  I would recommend you get a basic familiarity with SQL and JDBC (Java Database Connectivity) first.   After you are comfortable with the world of Java objects, and the world of relational databases and SQL, then you can learn Ebean/JPA (Java Persistence API)/ORM (Object to Relational Mapping) which connects the object world to the relational world.

ORM's are tricky and weird.  Most are eventually worth the struggle.  Ebean is the simplest one I know.  I'm more comfortable with it after 8 months than I am with Hibernate after 12 years.  I know a lot of people who use Spring with Hibernate and they don't seem to have any trouble, or even be particularly aware of what Hibernate is or does, so I'd say if you're going to use Hibernate, do it through Spring.  Maybe just because I've worked with it longer, I've managed to completely stub-out Hibernate with a couple of hash maps for testing, which is awesome (overview available on request).

You have some of the most important skills already.  Take the others one at a time and try not to get overwhelmed.

Body:
If you've got a good grasp of HTML, CSS, and JavaScript, you have a leg up on many people who end up doing web development.  The concepts behind JSP are very similar to PHP.  The quirks are different.  A servlet is the name for a chunk of Java code that serves a request.  That's it really.  The whole original Struts framework was a single servlet.

I would add Tomcat or Jetty to your list of technologies to learn.  Tomcat is the original Java Servlet Container implementation and happens to also be a fully featured and rather popular web server.  GlassFish is built on top of it.  I've been using Jetty instead of Tomcat in my newer projects because it's simpler, more flexible, and faster.  Jetty was designed to make web services as opposed to web apps.  But a web app is just a web service that serves HTML in response to raw HTTP requests, so if you understand HTTP (which you can learn the important parts of in a few hours to a day), it's very easy to work with.

You can make a little web site with Tomcat and JSP (tutorial here or JSF) knowing just what you know and spending a few hours going through tutorials.  That way you can start where you are comfortable before stretching out.  Then make a javax.servlet.http.HttpServlet that writes "<html><head><title>Hi</title></head><body><h1>Hello World</h1></body></html>" to the response object, list it in your Tomcat web.xml and send an HTTP request it from a web browser.  It's not rocket science.  All Java web frameworks are variations on those two basic activities.

If you go the Jetty route, it's even less structured.  Check out this Hello Jetty example.

If you're just going to make a blog or standard ecommerce site, I'd start with SquareSpace or Wordpress or something.  You get so much off the shelf, there's no way to justify custom coding any of that anymore.

The strength of Java for web applications is its reliability, maintainability, and performance.  PHP or Ruby/Rails is simpler, but Java will scale as much as you want to go.  I am not bowled over by any of the Java web frameworks.  When you have a team of people working on a large web application, or you need to use Hibernate, then a framework like Spring really shines.  Spring is the most popular.  When you have some familiarity with servlets and JSP/JSF, then learn how Spring ties those together with a data model.

If you are making a blog or a content management system, maybe you can get away with a NoSQL database.  But I would argue that NoSQL databases are basically just a caching layer on a file system, rather than replacing relational databases.  I think it's rare that a project that's a good fit for a NoSQL database is going to be appropriate to develop in Java.

Things that still require custom, high-performance code (in Java, PHP, whatever) are probably going to have a relational/SQL database powering them.  I would recommend you get a basic familiarity with SQL and JDBC (Java Database Connectivity) first.   After you are comfortable with the world of Java objects, and the world of relational databases and SQL, then you can learn Ebean/JPA (Java Persistence API)/ORM (Object to Relational Mapping) which connects the object world to the relational world.

ORM's are tricky and weird.  Most are eventually worth the struggle.  Ebean is the simplest one I know.  I'm more comfortable with it after 8 months than I am with Hibernate after 12 years.  I know a lot of people who use Spring with Hibernate and they don't seem to have any trouble, or even be particularly aware of what Hibernate is or does, so I'd say if you're going to use Hibernate, do it through Spring.  Maybe just because I've worked with it longer, I've managed to completely stub-out Hibernate with a couple of hash maps for testing, which is awesome (overview available on request).

You have some of the most important skills already.  Take the others one at a time and try not to get overwhelmed.


答:
The value of a generic data layer (a repository is a particular type of data layer) is allowing the code to change the underlying storage mechanism with little or no impact on the calling code.

In theory, this works well. In practice, as you have observed, the abstraction is often leaky. The mechanisms used to access data in one are different to the mechanisms in another. In some cases, you end up writing the code twice: once in the business layer and repeating it in the data layer.

The most effective way of creating a generic data layer is to know the different types of data sources the application will use beforehand. As you have seen, assuming LINQ or SQL is universal can be a  problem. Trying to retrofit new data stores will likely result in a rewrite.

[Edit: Added the following.]

It also depends on what the application needs from the data layer. If the application is just loading or storing objects, the data layer can be very simple. As the need to search, sort and filter increases, the complexity of the data layer increases and abstractions start to become leaky (such as exposing LINQ queries in the question). Once users can supply their own queries, however, the cost/benefit of the data layer needs to be carefully weighed.


答:
The issue isn't the repository pattern. Having an abstraction between getting data and how you're getting it is a good thing.

The issue here is the implementation. Assuming that an arbitrary expression will work for filtering is dicey at best.

Making a repository work for all of your objects directly kinda misses the point. Data objects will rarely if ever map directly to business objects. Passing in T to filter makes a lot less sense in these situations. And providing that much functionality pretty much guarantees that you can't support all of it once a different provider comes along.


问:
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.

答:
Whilst it's a nice idea that all project wiki pages follow a similar theme so that everyone knows where to find things, this won't really address the problem of developers not updating pages.

You need to find a way to get your developers to see enough benefit in doing these things that they drive it and want it done. Otherwise they will simply see it as another top down bureaucratic burden they could do without.

I've been in this situation, both where the wiki was a complete mess and where it was highly organised and formal. The wiki's state didn't effect the developers level of interested.


问:
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,

答:
You haven't given a lot of info but I think C is absolutely the right choice - I work as an Engineer in an industrial plant and most (if not all) of our code is written in C. If you need to get measurements from a device (I'm assuming a flow meter or thermocouple or similar here) and display it in near to realtime C is an excellent choice.

It's fast, portable (I've never written in C# but I don't think it works without a particular version of the framework installed and it is usually only windows based).

By all means you could use another language to do the GUI. But you could save yourself the effort and just use a pre-existing trending package (there are some good opensource ones available).

To summarize I'd say for the underlying interfacing with hardware part C is a fine choice.


答:
First off, you need to tell your boss it's in a different language, now. He'll be (understandably) angry if you bring back something purposefully against the requirements with no notice.

Now, the best way to explain these things to boss/managers is to put it in terms of time and money. Estimate how much time such a project would take in ANSI C, and then estimate how much time it would take in something higher level such as C#. Note I said higher level, not modern. This may help to smooth things over as well. I mean, you wouldn't tackle painting a room with just a tiny paint brush, you'd use rollers and other things that make each stroke(line of code) cover more area of the project. Also, if you or one of your team members do not know C, or comfortable making a large project in C, this eats into the time issue even more because they'll be having to get up to speed.

It also sounds like your boss is trying to micromanage. I'm sure one of the other answers will try to explain how to get your boss to do that less

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,