问:
Interpreted vs Compiled: A useful distinction?
A lot of questions get asked here about interpreted vs compiled language implements. I'm wondering whether the distinction actually makes any sense. (Actually the questions are usually about languages, but they are really thinking about the most popular implementations of those languages).

Today almost no implementation is strictly interpreted. i.e. pretty much nobody parses and runs the code one line at a time. Additionally, implementation which compile to machine code are also becoming less common. Increasingly, compilers target some sort of virtual machine.

In fact, most implementation are converging on the same basic strategy. The compiler produces bytecode which is interpreted or compiled to native code via a JIT. It is really a mix of the traditional ideas of compilation and interpretation.

Thus I ask: Is there a useful distinction between interpreted implementations and compiled implementation these days?

答:
The distinction is deeply meaningful because compiled languages restrict the semantics in ways that interpreted languages do not necessarily.  Some interpretive techniques are very hard (practically impossible) to compile.

Interpreted code can do things like generate code at run time, and give that code visibility into lexical bindings of an existing scope. That's one example. Another is that interpreters can be extended with interpreted code which can control how code is evaluated. This is the basis for ancient Lisp "fexprs": functions that are called with unevaluated arguments and decide what to do with them (having full access to the necessary environment to walk the code and evaluate variables, etc). In compiled languages, you can't really use that technique; you use macros instead: functions that are called at compile time with unevaluated arguments, and translate the code rather than interpreting.

Some language implementations are built around these techniques; their authors reject compiling as being an important goal, and rather embrace this kind of flexibility.

Interpreting will always be useful as a technique for bootstrapping a compiler. For a concrete example, look at CLISP (a popular implementation of Common Lisp).  CLISP has a compiler that is written in itself. When you build CLISP, that compiler is being interpreted during the early building steps. It is used to compile itself, and then once it is compiled, compiling is then done using the compiled compiler.

Without an interpreter kernel, you would need to bootstrap with some existing Lisp, like SBCL does.

With interpretation, you can develop a language from absolute scratch, starting with assembly language. Develop the basic I/O and core routines, then write an eval, still machine language. Once you have eval, write in the high level language; the machine code kernel does the evaluating. Use this facility to extend the library with many more routines and write a compiler also. Use the compiler to compile those routines and the compiler itself.

Interpretation: an  important stepping stone in the path leading to compilation!


问:
How do programmers quit a job?
I'm thinking about leaving my current employer and wondering how one goes about that process in the programming world. We have a lot of projects on the go at the moment and I'm the only developer. We have 4-5 projects that are fairly big and need to be done in the next few months and even a few longer than that.

I'm leaving because I'm the only employee and that's doing me no good. I'm young and want to learn, so a team would be nice. It's also too much work and the company is managed horribly.

I have no contract to worry about so I could theoretically quit and just not come back without notice. Just wondering how this is normally handled.

Should I write a resignation letter

How much notice should I give

Should I give a reason for leaving

Should I go to my boss who is the main reason I'm leaving or go to his boss?

Overview of replies

From the feedback here, it looks as though it's best to give 2-4 weeks of notice, and present a written resignation. Don't go into detail explaining why you're leaving in most cases. Don't burn bridges. Be professional.

答:
Poor management abounds in this world. Definitely stay on board until you have a place to land. Which means taking PTO time to go to interviews. Also, it's usually in bad taste to show up to work in interview clothes. So avoid doing that if you really care about leaving a bad taste in their mouth. If you don't care, meh.

You can write a letter to your current employer with a list of things that could make you stay, but, it sounds like you need to move on - there's nothing wrong with that - it's business.

On that note, meditate on some of the things that are deal breakers about where you are now. Make a list. Spend a good deal of time on the weekend assessing the root causes of those issues and try to build interview questions for your next series of interviews from them.

You want to be politically correct when you go into the interview, so if you have "bad management" on your list, enumerate on why you think the management is bad and then turn those enumerations into a list of questions for your next interview.

If they ask why you're leaving don't be too honest. Just say something like, "I'm looking to learn more professionally and where I am now, I can't really grow". Something like that. It avoids being overly critical about management, but at the same time, it's a true statement.

Once you find a good place to land, give your employer at least 2 weeks. From my experience most HR departments (sounds like you're in a small company) will take at least a month or two to process new personnel. I'd say if that's the case, give your employer at least a month's to a month-and-a-half of time to bail.

If you don't care - 2 weeks is the standard.

good luck.

ContentLicense: CC BY-SA 2.5

Title: How do programmers quit a job?


问:
Why doesn't Python need a compiler?
Just wondering (now that I've started with C++ which needs a compiler) why Python doesn't need a compiler?

I just enter the code, save it as an exec, and run it. In C++ I have to make builds and all of that other fun stuff.

答:
Not all compiled languages have an in-your-face edit-compile-link-run cycle.

What you're running into is a feature/limitation of C++ (or at least C++ implementations).

To do anything, you must store your code into files, and build a monolithic image by a process called linking.

In particular, it's this monolithic linking process which is mistaken for the distinction between compiling and interpreting.

Some languages do all this stuff much more dynamically, by eliminating the clumsy monolithic linking step, not by eliminating compiling to machine code. Source is still compiled to object files, but these are loaded into a run-time image, rather than linked into a monolithic executable.

You say "reload this module", and it loads the source and interprets it, or compiles it, depending on some mode switch.

Linux kernel programming has some of this flavor even though you're working in C. You can recompile a module and load and unload it. Of course, you're still aware that you're producing some executable thing, and it's managed by a complex build system, with still some manual steps. But the fact is that in the end you can unload and re-load just that small module and not have to restart the whole kernel.

Some languages have an even more fine grained modularization than this, and the building and loading is done from within their run-time, so it is more seamless.

ContentLicense: CC BY-SA 3.0

Title: Why doesn't Python need a compiler?


问:
Built in Scala library slow?
I found this question and accepted answer on StackOverflow. It's related to the slow JSON parser in the standard Scala library.

The consensus as it were,  is that the build-in JSON library is slow, and, in the words of DMC: "it's like that, and that's the way it is"

Maybe I'm just being naive here, but that sounds like a bad approach to grow the language. Shouldn't the built-in libraries be perfect? They don't have to be everything for everyone, and I accept that Scala is extendable. But, if there is a built-in library, then surely it should be rock solid and as fast as the language have to offer.

I'm lodging a complaint with Star Command ;-)

Does anyone know where or how a normal guy like me can voice my opinion on this, i.e. where we can go to help shape the Scala language?

Update:

This question was not intended in any negative way. Scala, it's creators and the Scala community is choc-full off goodness. I was simply surprised to see that something like the built-in JSON parser was far from optimal (according to the question in the link provided)

答:
Its open source software. So compared with proprietary software the authors tend to be more candid about any failings. There is also no pretense that you have any way to influence development other than polite requests, or, writing the improvements yourself and respectfully submitting the improved code for inclusion in the general release.

Given the nature of Scala and the niche it occupies (large scale parallel processing ) the developers are probably right to give priority to the internal performance of code that may be executed several thousand times for a single request versus a JSON parser that will be executed only once per request.

Title: Built in Scala library slow?


问:
How can I make sure that people changes his IP or not
I want to check that people who registrates in my site and check in country box , for example, Argentina is really living in Argentina.
How can I make sure that people is really living in that country and not access to my site via proxy or VPN?</p>

答:
There's no way to guarantee where a person is based on their IP address.  You can get a reasonable guess from GeoIP info.  But you cannot ever really be sure.  You can mess around with headers trying to guess if a proxy is being used, but headers might not always be there.

So, unless you have some legal reason to do this (for example, hosting content you're only licensed to make available in certain countries), or just want to annoy potential users who might be surfing via their company's VPN or remote desktop that happens to be hosted outside the country, I wouldnt even waste my time with it.


问:
What kind of copyright laws should I be aware of when creating software?
I'm trying to build a winform so I can play a web based game and have some other little utilities on the side. I do not plan on ever selling this or even distributing it to more than a handful of people.
My question is, Would I be infringing on any copyright laws if I use images from the game in my client?
I just want to be safe on the off chance the company does see it, I don't want to get sued.

Edit: I took a screenshot from the game and cropped out the icons for each skill that I will use as a link to skill guides, calculators, etc.
Also, I should note that I live in America and the company is based in the UK. I don't know if that affects anything or not.

答:
If you use images from a game and you dont have permission to do so (either directly, or via something like a creative commons license), then yes, you are violating the publisher's copyright.

Will you get sued?  Probaly not, but you never know.

Edit: Actually, you'll may want to be more specific about what you mean by 'use'.  If you are not actually copying the files, but instead loading them from the game's directories, I dont believe that would be considered copyright violation.

```<code>#include UsualIAmNotALawyer.disclaimer
</code>```

Body:
If you use images from a game and you dont have permission to do so (either directly, or via something like a creative commons license), then yes, you are violating the publisher's copyright.

Will you get sued?  Probaly not, but you never know.

Edit: Actually, you'll may want to be more specific about what you mean by 'use'.  If you are not actually copying the files, but instead loading them from the game's directories, I dont believe that would be considered copyright violation.

#include UsualIAmNotALawyer.disclaimer


答:
The built-in libraries should be perfect.

In an ideal world, yes. But perfect is the enemy of good. Any real creation is always some sort of trade-off. It can be a trade-off between performance and flexibility, for example. Or performance vs. the effort to write the library. If it's "good enough for now" and there are more critical issues to work on, then it's better to focus on those more critical issues. Optimizing for speed only is usually false economy.

One important point in language / library / API trade-offs is that changing interfaces later on is hard because it usually breaks old code built on top of the interface. But the implementation (i.e. speed) can be improved later on, so initially you can skimp on it, if it helps to focus the effort on getting the interface right. The order of importance is:

Interface. Syntax. File formats. Hard to modify after release. Must strive to get right initially.

Stability, correctness. Things should of course work as they're supposed to. But if not, can be fixed.

Performance, speed. Sometimes crucial, most often not. Can definitely be improved later on.

Does anyone know where or how a normal guy like me can voice my opinion on this, i.e. where we can go to help shape the Scala language?

I think the keyword here is "bottleneck". If you have a real use case where the performance of the JSON library is the bottleneck, then you could bring the issue up in Scala mailing list. If you can improve it yourself, good, but if someone else is supposed to improve it, there must at least be a genuine need for it.

Title: Built in Scala library slow?

Body:
I found this question and accepted answer on StackOverflow. It's related to the slow JSON parser in the standard Scala library.

The consensus as it were,  is that the build-in JSON library is slow, and, in the words of DMC: "it's like that, and that's the way it is"

Maybe I'm just being naive here, but that sounds like a bad approach to grow the language. Shouldn't the built-in libraries be perfect? They don't have to be everything for everyone, and I accept that Scala is extendable. But, if there is a built-in library, then surely it should be rock solid and as fast as the language have to offer.

I'm lodging a complaint with Star Command ;-)

Does anyone know where or how a normal guy like me can voice my opinion on this, i.e. where we can go to help shape the Scala language?

Update:

This question was not intended in any negative way. Scala, it's creators and the Scala community is choc-full off goodness. I was simply surprised to see that something like the built-in JSON parser was far from optimal (according to the question in the link provided)


问:
Does giving a developer a slower development machine result in faster/more efficient code?
Suppose I give my developers a screaming fast machine.  WPF-based VS2010 loads very quickly.  The developer then creates a WPF or WPF/e application that runs fine on his box, but much slower in the real world.

This question has two parts...

1) If I give a developer a slower machine, does that mean that the resulting code may be faster or more efficient?

2) What can I do to give my developers a fast IDE experience, while giving 'typical' runtime experiences?

Update:

For the record, I'm preparing my even-handed response to management. This isn't my idea, and you folks are helping me correct the misguided requests of my client.  Thanks for giving me more ammunition, and references to where and when to approach this.  I've +1'ed valid use cases such as:

- specific server side programming optimizations

- test labs

- the possibly buying a better server instead of top of the line graphics cards

答:
Interesting reading, all those answers.

But I think most people answering here are missing the point. The question, as I read it is not (only at least) about really giving the developers a P1 to make faster code.

The point is that a lot of software today is just as slow or even slower than the seftware we used back in last millennium in spite of very much more powerful computers. Judging from the answers here most developers don't get that hint. This is very obvious in web applications. This site is a very good exception, but many sites are having a front page in 1 mb. What do I get for waiting for that to download? I don't know. I think it seems to be about an ignorance from the developer not respecting the time the user need to spend on it, or even worse pay for if you pay per mb. The thing is that all those web pages is not even containing high resolution pictures. Often it is just some crap code delivered from some development-environment. Well, of course it is not crap code I guess, but it gives no gain to me as user.

In general it is not only about optimizing the code, but just as much about choosing to not include things slowing down more than the it gives.

A few weeks ago I started a laptop from 1995. Windows 3.x was up and running in no time. The database I should get some data from started before the enter key was fully released (almost at least).

I know that we get a lot more from our software today, but we also have computers many times faster. Why doesn't the development industry decide to keep the speed of software from 1995 and make people buy new hardware because they want new functionality. Today it is more like the everyday-programs and web sites forces people to buy new hardware to do exactly the same things as they did earlier. But of course in a fancier way.

I have to say I think the Linux development seems to handle this better. Linux distributions has for many years been quite far ahead windows even in fanciness with many eye candy things like animated windows. The thing is that they have in spite of that worked on the computers of today and even yesterday. Not only on cutting edge hardware.

By now I guess many developers have an unhealthy level of adrenalin. Yes, I found a way to give back some frustration from all waiting in front of:

office
sql server (starting up management console)
arcgis  (starting up and using)
acrobat reader  (starting up)
agresso  (using, at least as web application)
windows  (staring and using, well I haven't tried 7 yet)
.net web pages (downloading)

and so on

I feel good :-)

Cheers

Nicklas


问:
Tips/tricks to manage a new team with new code
How do you handle yourself in a new team where you are the senior most developer and most others in the team are junior to you by several years. The task ahead of the team is something nobody else including you has accomplished in their career before.

Management insists on higher productivity of the whole team, and as senior developer you are responsible.

Any tips for coming out trumps in a situation like this? Clearly, the entire team needs time to learn and let's not forget the team's new. However, deadlines are up ahead as well...

答:
What I have done is identify the capable ones and divide and conquer. I take the top 2 or 3 and make them captains. The others are then evenly split up into teams following the captains to their own little teams.

I give the captains chunks or modules to do of a program.

The captains give the newbies smaller programming or research tasks all the while explaining themselves what they are doing so mentoring happens while doing.

I try to arrange the room so everyone is in the same open space but each team is has their own circle of computers. I like to be in yelling distance to everyone so things move quickly.

This works well for about 10-20 programmers so far. The smaller groups are just better being in one group and I have not worked with anything larger yet.


问:
Methods of ordering function definitions in code
When I work on some programming project (usually command line application in Python with many switches), I'm usually creating about 30 and more functions. Most of the functions are in one file (except some helpers that I utilize in more projects).

Some of the functions are called on particular switch (like -p or --print) but many functions do some helper computations, print operations or database operations because I don't want to main functions be too large.

When I have an idea for a new functionality I often put new functions randomly to the file. Should I think more about it and place it to some particular place? Are there some methods for this?

答: These days, with IDE support for navigating stack traces and finding callers, I find it almost doesn't matter at all which order my methods come in. There is a slight benefit to having a small helper function near the place where it's called, particularly when it's called only in one place, but it's much more important to break your module into small functions in the first place than to order them sensibly. Trying to find the 'optimal' arrangement is almost certainly not worth your (pretty expensive, I hope) time. (Note also that automatically generated APIs are usually sorted alphabetically anyway, so whatever you do within your module doesn't affect others, either.)</p>


答:
I prefer the Clean Code version. If you start reading a function, each new self-implemented function call should be directly under it. For example like so:

```<code>func Foo()
    func1()
    funcWithFuncs()
    func2

func func1()
    stuff

func funcWithFuncs()
    funcA()
    funcB()

func funcA()
    stuff

func funcB()
    stuff

func func2()
    stuff
</code>```

That way, you can easily track which function is where even with functions that have more functions. Also, it doesn't require a call stack and running the program to easily find where everything is. Of course, this is a "taste" thing, but I haven't found Clean Code to be wrong on this point yet.

In contrast, I hate it when functions are scrambled because I DON'T KNOW WHEN TO STOP SCROLLING; I might miss it entirely, which happens more often than I want with larger code files.

Title: Methods of ordering function definitions in code

Body:
When I work on some programming project (usually command line application in Python with many switches), I'm usually creating about 30 and more functions. Most of the functions are in one file (except some helpers that I utilize in more projects).

Some of the functions are called on particular switch (like -p or --print) but many functions do some helper computations, print operations or database operations because I don't want to main functions be too large.

When I have an idea for a new functionality I often put new functions randomly to the file. Should I think more about it and place it to some particular place? Are there some methods for this?

Body:
I prefer the Clean Code version. If you start reading a function, each new self-implemented function call should be directly under it. For example like so:

func Foo()
    func1()
    funcWithFuncs()
    func2

func func1()
    stuff

func funcWithFuncs()
    funcA()
    funcB()

func funcA()
    stuff

func funcB()
    stuff

func func2()
    stuff

That way, you can easily track which function is where even with functions that have more functions. Also, it doesn't require a call stack and running the program to easily find where everything is. Of course, this is a "taste" thing, but I haven't found Clean Code to be wrong on this point yet.

In contrast, I hate it when functions are scrambled because I DON'T KNOW WHEN TO STOP SCROLLING; I might miss it entirely, which happens more often than I want with larger code files.


答: Given the abundance of fast open-source JSON parsers for the JVM, this looks like a perfect example of not invented here. A built-in feature that is magnitudes slower than already existing implementations is an indication that the makers of the language don't care too much about real-world usage, at least as far as this feature is concerned.

Title: Built in Scala library slow?


答:
If the creators of Scala were not to release any code until it is perfectly optimized to top performance, Scala would probably be at version 0.1, not 2.9.

Practically all new languages have performance issues initially. Think back to Java 1 (if you have any experience with it). This is because initially, the creators focus more on the language features and interfaces than the implementation details, and it is reasonable this way. Noone can predict how (and whether) a language and its class libraries are going to be used in the future (apart from the trivial cases like string library etc.). So it is better to optimize only when there is a real pressing need for it, than to spend time on optimizing a piece of code which won't actually make any visible difference in developers' life.

Moreover, Scala is special in that it is built on top of the JVM, so all the existing Java libraries are directly available from it. If you prefer performance over purity of language, you can always pick and use a suitable Java class / library.

Title: Built in Scala library slow?


问:
HTML5/Javascript + Web Services
If developing web applications using ASP.NET MVC or Ruby on Rails make the application use the MVC design pattern, then if I build my application using only HTML5/Javascript + backend webservices (like WCF rest), then which design pattern will my application follow?

答:
The modern web idea which you are talking about does not really have a specific name (it probably should). I generally try to use backbone.js or ExtJS or the like to do an MVC in the browser and treat the server as a data source that can have its own logic as well. </p>

<p>Don't worry so much about what it is called as much as how to write good code and make something that does the job. </p>

Title: HTML5/Javascript + Web Services

Body:
The modern web idea which you are talking about does not really have a specific name (it probably should). I generally try to use backbone.js or ExtJS or the like to do an MVC in the browser and treat the server as a data source that can have its own logic as well.

Don't worry so much about what it is called as much as how to write good code and make something that does the job.


答:
Focus on communication in two areas.

1)
As you and the team members gain a better understanding of what's involved (nearly always "more than originally thought", it's key to spend a lot of time explaining this to management.  There are few real deadlines.  I usually say that a NASA probe to an asteroid that will be in a certain orbital position only once every 200 years, now that's a real deadline.  Other than that most deadlines are artificial and often not based on the work.  They usually sound fixed becuase "we've only got that much money", "programmer bob leaves in 2 weeks", "We have to present to investors next week".  However, if the work isn't done, then these deadlines get missed.  Then what happens - reevaluate and decide what to do then.  In reality management would rather get that "bad news" up front.  It isn't easy to do this, and that's one reason this job is hard.  If meeting the deadline mean cutting features then go over that.  The one thing you're trying to avoid in all this is quick code to make a deadline.  That's the beginning of the end of a code base that will not last well and the beginning of technical debt that chokes.

2) Inter-team communication.  Set up formal practices like Bryan and others recommend.  Make sure that you meet regularly as a team, e.g. once a week in addition to daily scrums.  Gain respect and trust by listening, your most important tool.  Make sure you focus on helping.  Avoid negative criticism at all costs.  When necessary use positive criticism and encouragement, e.g. "that is great, once thing you might want consider is X" over "that is not what we need, you need to do X instead"

Title: Tips/tricks to manage a new team with new code

Body:
How do you handle yourself in a new team where you are the senior most developer and most others in the team are junior to you by several years. The task ahead of the team is something nobody else including you has accomplished in their career before.

Management insists on higher productivity of the whole team, and as senior developer you are responsible.

Any tips for coming out trumps in a situation like this? Clearly, the entire team needs time to learn and let's not forget the team's new. However, deadlines are up ahead as well...


问:
How can I move a team from C# ASP.NET development to PHP development using Drupal?
I have a team of skilled C# developers with vast experience in creating ASP.NET MVC applications. We will soon be starting a new big web site project based on the Drupal platform. My developers do not have any experience in Drupal or PHP and I want to make the transition as quickly and effective as possible.

We decided to make this decision based on two factors:

In my organization there are a couple of teams competing on doing this project. None of the other teams has experience in PHP or Drupal, and I truly believe that my team would do it the best, whether it's ASP.NET or Drupal.

One of the requirements from higher management was that we won't build something from scratch, but use an existing foundation. Many of the requirements are available in plugins/modules for the various CMS.

I know this is not an ideal environment, but it's a given state and I have to make the best out of it. None of the .NET Framework based CMS supported all of our requirements. Since my team is dynamic in nature, I believe it can adapt to working with Drupal.

Hiring other people is not an option, and sending them to a course will take too much time.
I thought about dedicating a week in which each developer will study a specific subject and then will pass it on to the team.

Any suggestions on how you would do it?

答:
I am assuming that your “skilled” C# developers are not very much in demand by other companies, maybe you are based somewhere with very few other jobs, or maybe your developers are just not skilled.

As a skilled and experienced c# developer, if I was told that I was going to be forced to move to Drupal or PHP I would be making use of http://careers.stackoverflow.com/

If your developers were keen to learn PHP they would have already started to do so in their own time, the fact they have not gained experience in Drupal or PHP of their own backs, must tell you how keen they are on the move!


问:
Why does Java define homogeneous methods in Matcher and Pattern classes
I wonder why java defines homogeneous methods in two distinct classes:  java.util.regex.Pattern and java.util.regex.Matcher.

For example split method defined in Pattern class and replaceAll method defined in Matcher class. I think these two methods are homogeneous, why are they not defined in the same class?

Have I understood it wrong?

By "homogenous", I mean: split and replaceAll methods are utilities for String, why not defined in a class?

答:
Not certain to be right, but :

When you create a regex, you have to cut/look inside the object you are searching for.

You have to know how it is made : you make a tool (split()) to detect the Pattern you like.

But when you use this tool, you want to make it usefull, so each time your pattern matches, you apply the rule pre-defined (replaceAll()).

How can you apply it if you do not know on what, this is not the same gesture/movement, so not the same class?

Forget you are a programmer and enrole you like an artisan, if now it is not obvious, find another point of view.

It is an language problem, each person have its meaning of words, often it is the same between them, sometime not, you have to guess what is behind the words wrotten which perturb your analysis.

Good 'declic'

Best regards
Claude


答:
Essentially, what you're building is a web browser. As you're aware, common web browser add toolbars. Some specialized webbrowsers have specialized toolbars as well, e.g. for Facebook. Your webbrowser would have a toolbar optimized for a game. That toolbar is yours; the game isn't. No copyright violation there.

However, do make clear that the two are distinct. You're safe on copyright, but trademarks can still hit you. You may use their trademark in a nominative sense (to identify the game), but not in a promotional sense (you can't suggest they endorse your browser)

Title: What kind of copyright laws should I be aware of when creating software?

Body:
I'm trying to build a winform so I can play a web based game and have some other little utilities on the side. I do not plan on ever selling this or even distributing it to more than a handful of people.
My question is, Would I be infringing on any copyright laws if I use images from the game in my client?
I just want to be safe on the off chance the company does see it, I don't want to get sued.

Edit: I took a screenshot from the game and cropped out the icons for each skill that I will use as a link to skill guides, calculators, etc.
Also, I should note that I live in America and the company is based in the UK. I don't know if that affects anything or not.


问:
Is it a good practice to use Auto Format the text?
I'm using Eclipse and I will talk about it as an example but I am sure that this is the case in any other IDE.

Eclipse has the CTRL-Shift-F command which automatically formats your code. Is it a good practice to use this kind of formatting?
I'm asking in the context of a big project in which there may be many programmers working on the same files and all these are administrated by a CSV system.

Thank you!

答: You should have a coding standard that you all follow.  Whether this is enforced by external tools (such as indent), or IDE, or by hand is kind of irrelevant. What is relevant is that it should be done any before commit.</p>


答:
As you have no doubt realised from all the other answers, forcing developers to make such a switch, especially on a project that sounds like it is going to be a highly visible, high pressure nightmare is not going to be easy.

My advice would be to ask the developers who would like the opportunity to work on the project, rather than force them. Although you will almost definitely end up with a much smaller number of developers working on the project, at least they will be on the project by choice and, as such, will be much more motivated to make it a success. Also, a smaller team will be easier to manage and generally more efficient, so you will get more bang for your buck. Sure, the project may, on paper, look like it is going to take longer than if you put all your developers on it, but that's only because the version of the plan that shows every single developer working in parallel on tasks that magically finish at the exact right times to ensure the earliest possible delivery date is a fairy tale. You should also receive extra kudos from upper management if you submit a proposal that uses significantly less resources than what the other teams are proposing.

Also, assuming you don't want to use any of the out-of-the-box themes, you will need a reasonable amount of web design capability and some very capable CSS developers. I mention this only because Drupal theming can be a bit more difficult than the HTML/CSS that goes into a regular web app. The good news is that there is tons of great documentation and some excellent tutorials available on customizing Drupal.

Title: How can I move a team from C# ASP.NET development to PHP development using Drupal?

Body:
I have a team of skilled C# developers with vast experience in creating ASP.NET MVC applications. We will soon be starting a new big web site project based on the Drupal platform. My developers do not have any experience in Drupal or PHP and I want to make the transition as quickly and effective as possible.

We decided to make this decision based on two factors:

In my organization there are a couple of teams competing on doing this project. None of the other teams has experience in PHP or Drupal, and I truly believe that my team would do it the best, whether it's ASP.NET or Drupal.

One of the requirements from higher management was that we won't build something from scratch, but use an existing foundation. Many of the requirements are available in plugins/modules for the various CMS.

I know this is not an ideal environment, but it's a given state and I have to make the best out of it. None of the .NET Framework based CMS supported all of our requirements. Since my team is dynamic in nature, I believe it can adapt to working with Drupal.

Hiring other people is not an option, and sending them to a course will take too much time.
I thought about dedicating a week in which each developer will study a specific subject and then will pass it on to the team.

Any suggestions on how you would do it?


答:
Yes it is.

Eclipse lets you define your own exportable code style which you can share among all your developers. If you don't want to setup your own formatting style, you may tell your developers to use Eclipse's default formatting. Even if you use the default one, I would advise you to export it and put it on a shared network drive for all developers to use. If later one, you decide to change one thing, you'll be able to easily.

Regardless, I would advise you to start as soon as possible, the best would be at the beginning of the project, and to keep your code always formatted to your chosen format. You'll want to avoid having pure "format commits" during the development because it's hard then to distinguish from "real" commits. What it means in practice is that developers should be rigorous with their commits.

Also, and I put it at the end because it is only my personal opinion, but consider removing the 80 characters per line limit (or extend it to something bigger, we have 120 characters here) which is, if I'm not mistaken the default auto-formatting line-length on Eclipse. We now all have big screens and big screen resolutions so it's ok. On that subject, check out the Is the 80-character limit still relevant in times of widescreen monitors question and answers, you may then be able to make your own decision.

Edit: Thorbjørn makes a good point about the "Format every time a file is saved" functionality.

Title: Is it a good practice to use Auto Format the text?

Body:
I'm using Eclipse and I will talk about it as an example but I am sure that this is the case in any other IDE.

Eclipse has the CTRL-Shift-F command which automatically formats your code. Is it a good practice to use this kind of formatting?
I'm asking in the context of a big project in which there may be many programmers working on the same files and all these are administrated by a CSV system.

Thank you!


答:
Yes, it is very good practice.  It ensures that everybody agrees how source files should look when being opened in an editor.

Additionally, I have had very good experiences with the "Format every time a file is saved" functionality. (We use the standard Eclipse formatter configuration).

Enable it by opening Eclipse properties, and select Java -> Editor -> Save Actions.  Enable "Perform the selected actions on save", and "Format source code".

The reason is naturally that code is always formatted, so you can format at will when editing without fearing anything breaks.  This also ensures that the source repository logs are accurate (which is important when doing forensic analysis).


答: It is a good practice to follow a well-defined coding standard in a project/company. The means of doing it though can vary, just pick whatever works best for you organization. If everyone uses Eclipse then you could just create an exportable code format for your projects and spread it between developers (Eclipse also has an option to format files automatically on each save), however I would recommend creating a document describing the chosen format.</p>


问:
Is Information Technology really Engineering?
While travelling I met a mathematician who was sitting near me. In a discussion he said: "...there is nothing like engineering in IT or rather programming". A true engineering is what Architecture is, what Electrical and Mechanical is.

It made me think and I was puzzled. A percent of my brain agreed also because in Indian Army, there is no subject like Computer Engineering in the Engineering Corps. They don't consider programming as engineering. This is what I heard few years back, I don't know what Indian Army thinks now.

What are your views?

答:
Software engineering is engineering, but IT or programming aren't. That's much like mechanical engineering is engineering and physics or welding aren't.

Software engineering is an incredibly young field (compared to other engineering branches), which it is actually hard to teach people, because there's not much experience to teach from. Only in the last 20-25 years has software become so big and complex that mere programming won't do the job.

Due to this shortcoming of established knowledge, actual software engineering is rarely taught. The only way you can become a decent software engineer is following the way of a craftsman: being mentored in the field. So while software engineering is an existent discipline, very few are actually in this field. Most people are doing software tinkering or software over-engineering.


问:
Advice on caching/updating data in memory for silverlight client
Currently in my Silverlight app I'm polling the database for changes to cached objects and am looking for advice on how to update the views that are displaying these lists.

Example:
I have a static class that has lists of objects (Areas, vehicles drivers etc.) that I will be using throughout the application.  I have a timer in my shell that will poll the database passing a timestamp of the last update.  So if the timestamp has changed the updates will be passed back and the lists will be updated.

How do I update the views that will be displaying these lists.  If the user is editing a record that displays a combobox bound to this list how will this data be updated and if the user has made a selection from the list will this affect the selection?

Bear in mind that some users will be adding to these lists that I will be inserting to the database.

Am I going about this in the right way?, or has anybody implemented this with success in their application?

答:
You can start by storing the lists in ObserableCollection objects (or one of thew other collection objects designed to notify changes to views) and bind controls in your views to those.

ObservableCollection generate change events when the contents of the list change (additions, deletions etc).

OwnerDisplayName: paul


问:
Functional Programming For Embedded Software
I was discussing F# and Functional Programming with a friend last night and he brought up an interesting question to me.  How would you do embedded software in functional?  I mean this seems like a fairly natural fit in terms of stateless code but embedded also entails being very frugal with memory and I'm not sure of the story for functional in that regard.

Any suggestions about languages or packages for embedded with functional?

答:
One option is Erlang. From the wikipedia page:

Erlang is a general-purpose concurrent, garbage-collected programming language and runtime system. The sequential subset of Erlang is a functional language, with strict evaluation, single assignment, and dynamic typing. For concurrency it follows the Actor model. It was designed by Ericsson to support distributed, fault-tolerant, soft-real-time, non-stop applications. It supports hot swapping, so that code can be changed without stopping a system.

While threads are considered to be a complicated and error-prone topic in most languages, Erlang provides language-level features for creating and managing processes with the aim of simplifying concurrent programming. Though all concurrency is explicit in Erlang, processes communicate using message passing instead of shared variables, which removes the need for locks.

The first version was developed by Joe Armstrong in 1986.2 It was originally a proprietary language within Ericsson, but was released as open source in 1998.


答: Using a polling technique combined with Timestamp version test could lead to performance problems in cases with lot of connected clients (>50).  If you have a limited number of clients, polling provides a cheap way to do it. In any case, you should always validate the data supplied by the user to ensure that it’s correct. In other words, if the user A deletes an entity and another user B uses the same entity, a validation should through an exception stating that entity is no longer exists.</p>

Title: Advice on caching/updating data in memory for silverlight client

Body:
Currently in my Silverlight app I'm polling the database for changes to cached objects and am looking for advice on how to update the views that are displaying these lists.

Example:
I have a static class that has lists of objects (Areas, vehicles drivers etc.) that I will be using throughout the application.  I have a timer in my shell that will poll the database passing a timestamp of the last update.  So if the timestamp has changed the updates will be passed back and the lists will be updated.

How do I update the views that will be displaying these lists.  If the user is editing a record that displays a combobox bound to this list how will this data be updated and if the user has made a selection from the list will this affect the selection?

Bear in mind that some users will be adding to these lists that I will be inserting to the database.

Am I going about this in the right way?, or has anybody implemented this with success in their application?


问:
MFC and WPF similarities
What are the similarities between MFC and WPF?

Is it worthy to learn MFC before WPF?

答:
MFC and WPF are completely different technologies and methodologies.

If you are getting into Windows desktop development right now then I'd recommend just learning WPF - this is the skill that will be transferable to to Metro development (both use XAML to define the UI).

MFC was used for C++ projects before .NET was developed and is effectively dead - except for legacy projects.

Title: MFC and WPF similarities


答:
In the main I agree with what everyone has said, but there are some practical points which may help you actually deliver something.

Your approach of having each developer take an area is not too bad. Incorporate into that a lot of prototyping. Create a list of tasks, something like the following and farm them out. Some are dependent on others, but it's just an example.

Install PHP and Drupal.

Create a build and deployment process

Configure a server and local developer instances

Build a plug in for Drupal that says "Hello World"

Build a PHP page which accesses data in a database

Set up the team as Drupal users, configure a Drupal workflow or similar.

and so on.

When you actually start composing the web site, borrow from Agile and focus on YAGNI, short sprints and visible progress. Aim to develop stuff in a way that makes it easy(ier) to refactor and replace.

Visible progress is essential here. Your goal is a working web site, so breaking tasks down into visible components, "Change page to do this" means you get to see progress and won't be thrown off course by developers working hard on something unrelated to the critical path.


答:
If you wish to learn C++ and have a future in the language then avoid MFC like the plague.  Nobody uses it anymore unless they are maintaining an old legacy application.  I worked at one place where I was assigned to fix a few bugs with a legacy MFC application and silly me, I thought that since I had a little C++ experience that I could just "pick it up".  It was one of the few times I found myself completely in over my head and thoroughly confused.

I couldn't tell if the application was designed and written poorly or if MFC was just an awful framework.  Fortunately I wasn't the only developer to have problems with it at that company, they eventually decided to rewrite the application in WPF and with good design and unit tests the application turned out rather extraordinary.

There is still work in MFC but you probably don't want these kinds of jobs.  WPF is more modern, and if your strengths are in C++ then just about any other C++ UI framework is preferrable to MFC.

Title: MFC and WPF similarities

Body:
What are the similarities between MFC and WPF?

Is it worthy to learn MFC before WPF?


答:
IANAL, but I do not think you will be violating any laws if you do not distribute your application (to anyone).

The people who made the game own the copyright on those images, and they control how the images are used. You cannot use their images for anything but personal use without their permission.


答:
Both MFC and WPF (along with Windows Forms, VB6 forms, and plenty of other things) contain concepts that come from the Windows UI - the basic set of controls (button, text box, checkbox etc), the idea of properties for those controls (text, contents, checked...) and that some properties are common to all controls while others are just for certain controls. They also have the idea of separating the definition of the UI (I want the button to be blue, and to have Click Me on it) from the code that runs when you interact with the UI.

However, the actual nuts and bolts of how they work, and what you learn while you're first using them, could hardly be more different:

MFC is for native C++ development, WPF is for managed code, primarily C# and VB. In theory you can do WPF in C++/CLI but the absence of a designer makes that pretty much a nonstarter

MFC "declares" the UI in code that is generated by a designer (x = new Button(...); kind of thing) while WPF "declares" the UI in XAML ( <Button> ... </Button> kind of thing.)

MFC contains a TON of classes that are not about UI, from the relatively harmless CString to the don't-go-there CDatabase.

If you're a C++ developer, don't learn C# so you can learn WPF. Instead, get your feet wet in XAML development by writing C++/XAML apps for Windows 8. (It's not hard.) If you're a C# developer, ignore MFC, it's not for you.

Title: MFC and WPF similarities


问:
Which commit to add issue/bug tracking ticket # to
I have been committing changes in git for a project over the last several months.  I would like to start integrating Trac into my workflow. Generally, I have the 'git flow' style of git repository.  I maintain a master and develop, and I branch features and bug-fixes from the develop branch.

I see from answers in Which commit should close a Github issue when multiple commits are responsible? that I want to link the "merge commit" to the ticket.

Since I already have several features in the git repository, I'd like to go "back in time" to associate them with a ticket that was entered in Trac.

At this point, I have two choices:

Re-write history. I can use git rebase --interactive --preserve-merges.  Then add the ticket information to the message.

Use git notes add <rev> to add a note.

I am looking for opinions on which is the better option.  1. allows me to be more in keeping with defacto-standards, while 2. allows me to keep ticket management separate from the code repository.

I have complete control over the repository, Trac server etc. Solo developer, no pushes (other than to a "backup", but I can rebuild that from the local)

答:
All of them. If a commit is relevant for the fix of issues X and Y, and another for Y and Z, they should both be marked as such. Why would you want to "artificially" reduce the number of commits to 1? If Trac doesn't support that, I'd say it's most definitely a bug (or "missing obvious feature").

Regarding the second part, do it the pragmatic way: Which option is best supported by the tools you use (or want to use), taking into account that any changes to the history will lead to extra work for those who want to update their repo.


问:
What are effective ways to introduce the concept of code kata into the workplace?
In your experiences, what are some effective ways to introduce code kata practice into an organization or company?

To be clear, I'm not concerned with the usefulness of code kata. I'm interested in methods to introduce this concept to a development team.

答:
The question is "effective ways to introduce X into the workplace". I will not discuss if you should or should not. The way to introduce it is to look at your own organization and determine who is in the right position to introduce it.

In some organizations the best approach is through management. They rule some workplaces, so anything that they don't think is beneficial will be squashed. Otherwise participants will be forced to hide it from management, thus limiting its effectiveness.

In other workplaces the best approach is to get buy-in from a senior developer. They can encourage others to participate. They can get their entire team/project involved.

The 3rd approach is to get another respected developer involved. They have earned enough leeway that their time invested in X is not seen as a waste of time.

After it is introduced, be prepared to collect data and prove that it: increases productivity; reduces defects; or reduces training time.


问:
How can I demonstrate my productivity to management?
My university has a module for software development with a real client. Some of my team members work in the computer lab all the time, which is an extremely noisy environment with lots of interruptions and distractions. There are about 30 people always talking. People always go on Facebook, YouTube, or tell jokes to each other in addition to doing "work". Some of my team members work 3 hours every day in this environment.

I attend our weekly team meetings and use our online project management system extensively. I address all emails and have a chat client on busy, but I do get messages. I use online resources a lot when solving my problems. However, outside the team meeting and pair programming sessions, I do most of my work in a quiet environment where I can focus and concentrate and I block out all external as well as internal interruptions. I focus on my task 100%. I find that I'm about 10 times more productive this way than in the lab and I can get a lot of work done.

The problem is that our tutors or "management" don't see me doing work in the lab. Thus, I do not appear to be working to them. Thus they think I do no team work. How can I convince them that I do team work because I have lots of communication with my team, but at the same time I like to work on my own? I would like to prove that, just because I work alone a lot and don't necessarily do all of my work in the lab, I'm still a productive member of the team.

UPDATE Management told me that the problem was that I spend working in a team 60% of my time, and I work alone 40% of the time. They told me I should spend 99% of my time working with my team face to face in the lab, aka office.

Some relevant comments of some answers, that some might miss:

"Problem is I don't really need to ask my team anything, because I rather google it myself. And I trust Google a lot more than my supervisor or team members for some reason. Hence I often disagree with them. I'm not doing team work, because essentially I'm doing "web" work."

" I trust information that I find online (i.e. SE) more than my supervisor's or team mates' expertise."

UPDATE 2
I stopped doing any serious work at home, I just stay in the lab now and have fun with my team while also do some work occasionally. As the accepted answer shows, this isn't about me being productive but rather fulfilling my managers' and team mates' expectations. If I and my manager have different beliefs about how to do software development, it's the manager's that counts because they have the power to fail/fire me. In my opinion face to face meetings aren't as effective as online conversations, and working in a noisy lab isn't as productive as working in a quite environment. I think team mates shouldn't be able to interrupt me any time they want, while I'm in the middle of a task. I think one needs at least 50% of the time to do productive work alone and 50% of the time to synchronize with the team. Anyway, this is just my opinion, and that doesn't count in this case.

答:
It seems to me, that in this situation, all the external references won't be a major help, instead what I would do is take records from your project management system showing everything you have contributed. If the system can produce a chart of your activity for a time span, even better and take that too.

Also, take along the minutes from your weekly face-to-face meetings showing you have taken part and contributed in those meetings.

In addition the chat logs from your chat client where the chats are related to the work, showing you answering the questions of your team, even when you aren't physically in the lab.

If the rest of your team recognise your effort, ask if you can take one of them along (ask first though), if not try getting them to send you a statement outlining the major contributions, from their point of view, that you have helped with.

All the external references won't help you if you can't show that you have been contributing to the team, and that the team recognise that contribution.


答:
The first thing that I'd recommend is having your team get involved. If you truly are being productive and contributing positively to the team, the people you are working with should be more than willing to say this to the appropriate people at the right time. They would be best suited to speak to your strengths, weaknesses, and measure your contributions in terms of its value to the project. This is why, in all of my experiences, colleagues and teammates provide assessments and evaluations of each other to management (or, at university, the professor) for consideration - these are the people who know you best.

If you need more concrete data, you should have plenty of it, since you are using email and a project management tool. Hopefully, you should also be using a version control system. You can show how long it takes you to respond to emails (and IMs if you are logging IMs) related to the project. You can show check-ins and merges from version control, with diffs to show what you have contributed. You can show the tasks that you have completed (and depending on how your PM tool is set up, time tracking).

Another avenue would be to discuss the lab environment with the people who manage/operate it. If it's truly supposed to be a work environment and people are distracting you from working, it's not meeting its purpose. This might be something that needs to be addressed to ensure that people have a productive environment. You can't expect a silent team space, since teams will have conversations. But I don't think it's too much to ask to have a space that's dedicated to work-related discussions at a reasonable volume.

Given your more recent edit, I don't think there's much you can do.

At my job, I spend about 8 to 10 hours/week in a team environment. Yes, we need to coordinate activities and resource utilization and plan tasks and so on. But the other 32 (and usually more like 35+) hours/week are me working on my assignments solo. However, I am available (as in have email notifications on, IM client on, at or near my desk to answer my phone or check for messages) far more frequently.

In order to maximize team communication and productivity, many companies have the notion of "core hours". These are hours that everyone on the team not on vacation or some other scheduled/approved leave is expected to be available. This applies equally to people with virtual presence as well as actually in the office. Where I work now, core hours are 6 hours a day (I think 5 hours on Friday), and different teams make slight modifications to core hours.

The "99%" asked for by management is probably a little extreme. However, being readily available 75% of the time, and answering emails, calls, and IMs during occassions when you aren't with the group physically, is not out of the question at all. Even if you don't think these are urgent, your lack of a response could be blocking someone else.

Title: How can I demonstrate my productivity to management?

Body:
My university has a module for software development with a real client. Some of my team members work in the computer lab all the time, which is an extremely noisy environment with lots of interruptions and distractions. There are about 30 people always talking. People always go on Facebook, YouTube, or tell jokes to each other in addition to doing "work". Some of my team members work 3 hours every day in this environment.

I attend our weekly team meetings and use our online project management system extensively. I address all emails and have a chat client on busy, but I do get messages. I use online resources a lot when solving my problems. However, outside the team meeting and pair programming sessions, I do most of my work in a quiet environment where I can focus and concentrate and I block out all external as well as internal interruptions. I focus on my task 100%. I find that I'm about 10 times more productive this way than in the lab and I can get a lot of work done.

The problem is that our tutors or "management" don't see me doing work in the lab. Thus, I do not appear to be working to them. Thus they think I do no team work. How can I convince them that I do team work because I have lots of communication with my team, but at the same time I like to work on my own? I would like to prove that, just because I work alone a lot and don't necessarily do all of my work in the lab, I'm still a productive member of the team.

UPDATE Management told me that the problem was that I spend working in a team 60% of my time, and I work alone 40% of the time. They told me I should spend 99% of my time working with my team face to face in the lab, aka office.

Some relevant comments of some answers, that some might miss:

"Problem is I don't really need to ask my team anything, because I rather google it myself. And I trust Google a lot more than my supervisor or team members for some reason. Hence I often disagree with them. I'm not doing team work, because essentially I'm doing "web" work."

" I trust information that I find online (i.e. SE) more than my supervisor's or team mates' expertise."

UPDATE 2
I stopped doing any serious work at home, I just stay in the lab now and have fun with my team while also do some work occasionally. As the accepted answer shows, this isn't about me being productive but rather fulfilling my managers' and team mates' expectations. If I and my manager have different beliefs about how to do software development, it's the manager's that counts because they have the power to fail/fire me. In my opinion face to face meetings aren't as effective as online conversations, and working in a noisy lab isn't as productive as working in a quite environment. I think team mates shouldn't be able to interrupt me any time they want, while I'm in the middle of a task. I think one needs at least 50% of the time to do productive work alone and 50% of the time to synchronize with the team. Anyway, this is just my opinion, and that doesn't count in this case.


问:
Learning system instead of using sed/replace for reviewing test results
For every build of my software I run it through a series of tests that execute a number of commands on a command line and captures the results.

Most of the time the output is a combination of:
  - Static information that is, and should be, the same between every run.
  - Dynamic information that is not easy to predict.

For the purpose of testing this software I desire to only verify that the static information is the same between each test.

Currently I use sed on the captured output of my automated tests to filter out the dynamic information. Any differences between test runs are then identified using the filtered data resulting from applying the sed rules.

Because of the large variety of command output that is processed, maintaining the sed rules has become an onerous job.

Is there a system, that with a large sample of executed test results, can show uncommon changes between two files contained in that large sample of test results?  To clarify, if I were to diff two files, I would only want to see differences for items that changed 5% of the time between all the files involved.  Any other data that changed 95+% of the time would be excluded as differences when comparing two of the files within the large set of test results.

In this example, among the large set of test runs, the first column is almost always consistent:

Run 1:

```
1/*/1    6643   2433   12343   232424    112
2/1/1    2311    455    1342    60233   5231
2/1/2    2355   1223      93    12389   1342
```

Run 2:

```
1/*/1    3121    112   98832      451   1233
2/1/1    6342   2345   84421     3456   8362
2/1/2   72453      5     421    64321   7634
```

Run 3:

```
1/*/1      12     65     312      653    973
2/1/1   12442  54231   46012        6    734
2/1/3     734     28     623       76   1834
```

On top of the three runs above, there are hundreds of samples of this same commands output generated for each incremental build of the software.
When performing a difference between each of the three examples above I would like to have the following results:

No Differences between Run #1 and Run #2. Difference showing that "2/1/2" was changed to "2/1/3" when asked to show the difference between Run #3 and either of the other two runs.

Currently I have a sed script that replaces all the "random looking" numbers above (counts, timestamps, etc) with hashmarks or other constant indicators so that all that is left to compare is the starting column.

What options, if any, exist in this area?  Is there a name for this kind of text comparison?

答:
It should be a matter of building a histogram for each field, then finding the most frequent value.  If that value's frequency is more than 95%, it's a "static" field.  Once you know which fields are dynamic, your idea of replacing them with a marker is a good one, or you can diff against the most frequent value from the histogram.

The most efficient way to build a histogram  is to make a hash table with the field's values as keys.  Each time that value appears in a run, you increment the counter stored in the hash table.


答: Putting yourself in a position of needing to prove your productivity usually results in getting fired.  Like it or not, part of your chosen profession involves interacting with your colleagues during work hours, even outside of meetings.  Bring in some headphones to drown out distractions with music.</p>


问:
Is it reasonable to run processes with CI tools?
At my company, we have a quagmire of disparate cron jobs (on multiple systems) and manually kicked off processes which keep our business functioning that is a result of years of expedient development and subsequent neglect.

Someday, we will need to come up with a more centralized solution for obvious reasons.

One thought that we have been kicking around is to use our Continuous Integration software (Jenkins) to run these processes, which seems logical.

My question is: Are other companies doing this? Is this a generally accepted practice? Doesn't this conflict with the definition of a CI tool implicit in its name? Are there any other options?

Note:
https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins

Jenkins claims that it focuses on "Monitoring executions of externally-run jobs, such as cron jobs and procmail jobs". I'm not sure if this is exactly what I am talking about.

答:
Do not use CI for running periodic tasks that not related to build.

Also avoid cron for tasks that not related to system maintenance.

Use right tools. For application needs - try to use AMQP based solutions.

P.S. I see, that cron fits for your case. On other hand you have a lot of tasks - so try to write supervisor app for them.


答:
MFC is an old class based wrapper around Win32, its not particularly difficult to learn and use but it is pretty much legacy today.

WPF is a .NET only GUI technology based around an XML-style declarative layout. This is kindof like HTML with javascript, only it used C# for the code-behind aspects.

So they're totally different.

You should look into  a few more options before making your mind up. There's the well-respected Qt for C++ developers (and its extensions in the form of QML and Wt), or HTML. Microsoft has said that HTML5 is its (new) primary GUI technology and a lot of other companies are doing work with it, so you might see more developer resources ploughed into that compared to all the other GUI technologies put together.

Title: MFC and WPF similarities


答:
You need to use an enterprise service bus (ESB) for this type of task.

Now my background is in windows/BizTalk, but I am sure that all the equivalents exist on the unix side of things as well. What we would normally do is set up processes on the BizTalk box that would be in charge of kicking off things on the other box, monitoring the progress/errors, and reporting back the status to SharePoint (or web) portal, or sending emails and such if it needs attention.

The benefits of this approach is that all of the configuration and management of your various businesses processes are centrally located, so you know where to start looking. The software already exists that lets you abstract the coding part from the physical config (in BizTalk you can program against a logical 'port' like a sql server, and then in prod, if a sql box changes location or is upgraded or whatever, you can change the configured physical port using their admin tool, again, I am sure equivalents exist on the unix side).

The benefits over using a CI tools would be things like, if your process error out you can automatically, physical resubmit the messages and you can set up a clustered fail-over environment, having a better suited record and logging system; also, once you have the system in place, it would allow you to start architecting your organization to use, or better utilizing SOA. The down side is that depending on the size of your organization the development effort might be high, and licensing costs may be prohibitive.

Title: Is it reasonable to run processes with CI tools?

Body:
At my company, we have a quagmire of disparate cron jobs (on multiple systems) and manually kicked off processes which keep our business functioning that is a result of years of expedient development and subsequent neglect.

Someday, we will need to come up with a more centralized solution for obvious reasons.

One thought that we have been kicking around is to use our Continuous Integration software (Jenkins) to run these processes, which seems logical.

My question is: Are other companies doing this? Is this a generally accepted practice? Doesn't this conflict with the definition of a CI tool implicit in its name? Are there any other options?

Note:
https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins

Jenkins claims that it focuses on "Monitoring executions of externally-run jobs, such as cron jobs and procmail jobs". I'm not sure if this is exactly what I am talking about.


答:
It strikes me that what your Univ is trying to teach is perhaps different from how you are understanding the assignment.

It is a well proven fact that most programmers are more productive when working without interruption. In fact if you are concentrating on a hard conceptual problem and the phone rings (even if you don't answer it) it can take you a half hour to get your concentration back.

It is also a well known fact that many, if not most, programming shops do not offer an environment that permits that level of concentration. In fact many are more like sweat shops.

If what they are trying to teach you is how to work with teams in "real world" conditions that you are likely to experience on the job, then what they are doing is appropriate. If on the other hand their goal is to teach you how to be productive they fail miserably.

I don't know if it is fair to compare programming with writing, but certainly both involve creative thinking and concentration. Many great authors write their books in a sequestered place free of interruptions. In fact many are recluses or eccentrics yet produce highly prized literature.

There is a class of writers however who traditionally are forced to work in nosy conditions like your lab and they are reporters and war correspondents. In journalism school one of the standard "labs" was a room full of typewriters where students are given an assignment and called upon to produce an article under timed conditions of just a few minutes. A writer who can't produce under tight deadlines and nosy conditions probably should not be a war correspondent on the front lines.

Finally understand that some of the best software is written by individuals rather than teams. As they say, "a camel is a horse designed by committee".

My recommendation is to sit down with your professor and ask him what he is attempting to achieve by having a lab that is loud and where people joke around? If it is to simulate a typical work environment then you need to be prepared for that or else try to focus on finding an employer with a much better work environment. They do exist, consider Microsoft where everyone gets a private office (or at least they used to).


问:
Mobile applications in Delphi
Many of us know that Delphi executables are little bit gigantic, but again it is acceptable as nowadays 1.5 mb is not a big issue in PC.

But what about mobile devices? Currently Firemonkey supports iOS and in the near future it is going to Android and so on. Isn't 4 mb of executable size for mobile devices is too much for a simple application?

Will Delphi team try to reduce the size of executable in the future OR is it possible to do without loosing most of the features in Firemonkey?

答:
It is almost 100% certain that the answer is no.

First, the commercial reality of commercial products; It is impossible for a commercial application to grow and succeed by decreasing its features.

So the answer to whether or not it is likely that smaller applications will become possible, using a framework, is NO, because the only likely change in future is that each empty app will become larger and larger as the support code which enables more and more features in each release, grows larger and larger.

If you want the absolute smallest applications, you will have to natively develop a completely separate codebase for each mobile platform that you wish to support.  You probably are aware that by doing things this way, you will get the absolute smallest app possible on each platform, but you will have to rewrite each app almost completely (you can share assets like bitmap images and sounds between platforms, but that's about it.)

Title: Mobile applications in Delphi


问:
How can I test a parser for a bespoke XML schema?
I'm parsing a bespoke XML format into an object graph using .NET 4.0. My parser is using the System.XML namespace internally, I'm then interrogating the relevant properties of XmlNodes to create my object graph.

I've got a first cut of the parser working on a basic input file and I want to put some unit tests around this before I progress on to more complex input files.

Is there a pattern for how to test a parser such as this?

When I started looking at this, my first move was to new up and XmlDocument, XmlNamespaceManager and create an XmlElement. But it occurs to me that this is quite lengthy and prone to human error. My parser is quite recursive as you can imagine and this might lead to testing the full system rather than the individual units (methods) of the system. So a second question might be What refactoring might make a recursive parser more testable?

答: Create a separate test project, add a reference to your parser project, write your test class, and add your test document as an embedded resource (under "Build Actions").  In your test class, use Assembly.GetExecutingAssembly().GetManifestResourceStream('test-data.xml') to get your test data as a stream.  You should be able to feed that stream to your parser and run your tests.


问:
Built in Scala library slow?
I found this question and accepted answer on StackOverflow. It's related to the slow JSON parser in the standard Scala library.

The consensus as it were,  is that the build-in JSON library is slow, and, in the words of DMC: "it's like that, and that's the way it is"

Maybe I'm just being naive here, but that sounds like a bad approach to grow the language. Shouldn't the built-in libraries be perfect? They don't have to be everything for everyone, and I accept that Scala is extendable. But, if there is a built-in library, then surely it should be rock solid and as fast as the language have to offer.

I'm lodging a complaint with Star Command ;-)

Does anyone know where or how a normal guy like me can voice my opinion on this, i.e. where we can go to help shape the Scala language?

Update:

This question was not intended in any negative way. Scala, it's creators and the Scala community is choc-full off goodness. I was simply surprised to see that something like the built-in JSON parser was far from optimal (according to the question in the link provided)

答:
The JSON parser that comes with the standard library is based on the parser combinators. Parser combinators makes it possible to create parsers that are easy to understand and modify, and do so very quickly. The whole grammar for JSON is defined on lines 134 to 140 here. If you take a look at Lift JSON, you can't even pick a group of lines as representing the grammar.

However, parser combinators -- the Scala library at least (Haskell has them too) -- are slow. Maybe the packrat parser introduced on Scala 2.8 would perform better, but that JSON parser is much older, and, if I have my facts straight, it was created mostly as an example.

Now, should Scala only make available perfect libraries? Well, given the constrained resources available, the alternative is no JSON library at all. Today, that would be fine -- there are plenty alternatives, after all. But at the time JSON was added to the library, and before the widespread adoption of JSON made it performance-critical, it was something nice to have.

Title: Built in Scala library slow?


答:
The mere fact that you are asking this question here indicates that you either haven't spoken with your team about this, or you have and they have indicated misgivings. Either way, you can throw any number of courses or training seminars at your team, if they are not on board, they will not support you and you will fail. Remember, they started working for you for a reason. Realize that you are, potentially, altering a lot of the parameters that made them choose to come work for you in the first place.

Sit down with your team, figure out together how to go about this transition and if it's feasible. Figure out how to share credit as well. Your post here talks a lot about you and how you need to impress management and how your developers should me made to fall in line. If this is to get done, it will have to be a group effort so start from there.

You can force your team to your will up to a point (that's why they call it work, you get paid to do as you're told). However, eventually people will either scale down to producing the bare minimum to get paid, or they will simply quit. Either one of which will surely doom your project to failure.


问:
What is the differences between committing and patching?
I am quite new to source control and would like to know the differences between committing and patching? Also, how/when a patch is use and can it be used on a web application?</p>

答:
I'm not sure about git/mercurial, but here is what I think based on what I know about CVS, since I've used patches only there, though I'm pretty sure it works/is used the same way.

When you "commit", you effectively override the remote version of the file with the one on your local repository. What you commit is in fact a "patch".

A patch is a file containing the set of differences between
  two version of one or more files.

Patching is when you get a patch from someone else (say, by email for example), in order to be able to merge your local version with the version of the person that submitted the patch, while not merging with the version on the remote repository. This often happens because the person that provided you the patch has no write authorizations to the repository.

So basically, a person can create a patch containing the set of differences of one, or multiple files between two versions. And another person can apply the patch to its own version and then commit the patch to the repository.

As to why it is used, the scenario I described above when one person has no access is valid. Another use is that you can give/commit patches if you don't want to commit the whole changes you made. For example, you made three changes to one file, but the last change is some debugging code that is not destined to be committed, so you create a patch, you remove the last change from the patch file, and your patch is ready to be sent/committed.

Finally, as for your last question, it can be used for any type of application where the code is stored in a repository.

Edit: A concrete example: you can submit a patch to fix a Github project where you don't have write access.


问:
HTML5/Javascript + Web Services
If developing web applications using ASP.NET MVC or Ruby on Rails make the application use the MVC design pattern, then if I build my application using only HTML5/Javascript + backend webservices (like WCF rest), then which design pattern will my application follow?

答: I call that "web app" development or "fat client" where you are including all your GUI interactivity on the client-side and the server is only providing data. MVC is more akin to "Enterprise Web Applications" or as I call them "pretentious layers of software".</p>

Title: HTML5/Javascript + Web Services


答:
Patch can be applied anywhere -- to a working copy, or to a repository. It's just a file format that lists the changes necessary to bring code from one state to another. Version control need not be involved. </p>

<p>A commit saves a set of code changes (similar to what a patch references) to the source code repository (e.g. Mercurial/Git repo). From there, whenever anyone checks out the latest code it will include that commit. </p>

Title: What is the differences between committing and patching?

Body: I am quite new to source control and would like to know the differences between committing and patching? Also, how/when a patch is use and can it be used on a web application?</p>

Body:
Patch can be applied anywhere -- to a working copy, or to a repository. It's just a file format that lists the changes necessary to bring code from one state to another. Version control need not be involved.

A commit saves a set of code changes (similar to what a patch references) to the source code repository (e.g. Mercurial/Git repo). From there, whenever anyone checks out the latest code it will include that commit.


问:
What should be the workflow with a git repository?
I work on several git repositories though on most not more than 2 people work. Mostly me and my boss. Very often when we work in parallel it happens that "git log" doesn't look so nice because of the merge commits. My boss always complains about that. I really hate that fact because this makes me effectively serialize my work. To prevent these merge commits I must always rebase to the most recent version and go to the other office to make sure that my boss doesn't forget to process the merge requests before committing stuff himself. Even worse he told me that since one week or so he doesn't get email notification for merge request, though I have problems to believe that.

Even more worse he now does himself merge request for peer reviewing, elevating the problem more. (The best part is he thinks I always forget to rebase and update on time...) On several occasions I already tried to explain to him that I do everything the way he suggests but he doesn't believe me because he has more experience with git, at least in non-teamwork-environments.

I work at this place since 3 months, though I actually do teamwork since a few weeks. I really wished we would use svn because with this workflow in git I waste a lot of my time and I get a headache. In particular we have about 40 repos with modules which are in most cases not longer than 3000 LOC. So when I change something intimate in Repo A I might have to change something in Repo B. If I was deciding, I would put all that stuff into one repo, at least the modules which belong to one group of software.

Of course as a new employee you cannot critisize your boss too much or influence him too much. So what is the best way to deal with this problem?

答:
There are several issues here:

Using git over svn.

git is better because it's distributed.

git has also become a standard because of issues like this.

Relations with your boss.

Clearly you're in a tough spot.  In situations like this, 'stop by' or 'hallway' comments will not work.  I would recommend you request a formal meeting with him/her about an item that you are very worried about.  Use that "very worried about" language in your meeting request but do NOT say what it is about at all.  This will get his/her attention!

Industry Standards.

With development today it's very important to keep up to date on tools and things change quickly.  Unlike when I programmed 30 years ago and tools could be standard for a decade.  I would consider using this and other posts in your meeting with your boss.. although this question and answers will probably piss 'em off due to the criticism.  So maybe other questions on the same topic.

Final Note:

My last boss used svn and when I tried to talk about how git was better I got the snarky "svn is a perfectly good system, I've been using it for year, it's not like it's fallen by the wayside".  The truth came out though when someone - ok it was me - screwed up some code.  He then had a hellavu hard time backing it out. Pretty ironic given that this is a super major point of a version control system.  So basically svn worked well... until we actually needed key features.  I probably should have known this given that he hadn't been to user groups in 3 years, doesn't have a good SO account, etc.

Given your descriptions I would also polish up that resume and make sure you're in touch with the market!  Folks that you want to work with will be happy that you're using git !


问:
Best way to use source control for a project (1-3 people)
So my partner and I are working on a practice management system and at first we didn't use any version control, then I persuaded him to use git. At the moment our system is that we have three branches: develop, master and release. Our git repo is on an external server, which has Apache, MySQL, etc. We do our daily coding on the develop branch (commits) and then we we have done some testing to make sure it's (semi) bug-free we merge it into the master branch. If we want to do something radical we just make a branch of master, mess around and if it works, good, we merge it back in, if not, we delete the branch.

Finally when we go for our weekly release we merge to the release branch to make sure we have a copy of the project as it was when we released. Unfortunately we don't track all files in git as it slows down git too much (e.g. images, especially since this is on an old server with a single-core 1.4 GHz AMD Sempron), as a git status usually changes from around 3s to about 1 minute; or because we can't (mysql databases). For us the slowdown is not workable so we just leave them out, and this has never seemed to be a problem because we haven't deleted any images, but we may start to soon as we start to optimize. So when we checkout previous commits sometimes the files aren't there and so it is broken (a big problem is we can't use version control on the database (because we don't know how), so because the schema has changed it is also broken if we go back).

And that's pretty much our workflow.

So after my background, my question is: Do you think that there are any improvements we could make to the above?

And on a side note: Does any know a reliable and easy-medium difficulty (i.e. not too hard) way to track mysql databases in git?

答:
I really like tdammers answer!

The one thing I would add is:

To address the issue of too many tracked files such as images, maybe those directories could be added to .gitignore and just handled separately.  However this is not a great solution.  You're probably better off buying a more powerful machine if you think machine power is an issue.  Always consider Your Time X Your Hourly Rate in that cost calculation.


问:
Base classes as factories?
I was writing some code over the weekend and I found myself wanting to write a factory as a static method in a base class.

My question is simply to know if this is a c# idomatic approach?

My sense that it might not be comes from the fact that the base class has knowledge of the derived class.

That said, I'm not sure of a simpler way to get the same result.  A whole other factory class seems (to me at least) like unneeded complexity (?)

Something like:

```<code>class Animal
{
  public static Animal CreateAnimal(string name)
  {
     switch(name)
     {
        case "Shark":
          return new SeaAnimal();
          break;
        case "Dog":
          return new LandAnimal();
          break;
        default:
          throw new Exception("unknown animal");
     }
  }
}
class LandAnimal : Animal
{
}

class SeaAnimal : Animal
{
}
</code>```

答:
Well, the advantage of a separate factory class is that it can be mocked out in unit tests.

But if you're not going to do that, or make it polymorphic in any other way, then a static Factory method on the class itself is OK.

Title: Base classes as factories?


答:
You could use Generics to avoid the switch statement and decouple the downstream implementations from the base class as well.:

```<code> public static T CreateAnimal<T>() where T: new, Animal
 {
    return new T();
 }
</code>```

Usage:

```<code>LandAnimal rabbit = Animal.CreateAnimal();  //Type inference should should just figure out the T by the return indicated.
</code>```

or

```<code> var rabbit = Animal.CreateAnimal<LandAnimal>();
</code>```

Title: Base classes as factories?

Body:
I was writing some code over the weekend and I found myself wanting to write a factory as a static method in a base class.

My question is simply to know if this is a c# idomatic approach?

My sense that it might not be comes from the fact that the base class has knowledge of the derived class.

That said, I'm not sure of a simpler way to get the same result.  A whole other factory class seems (to me at least) like unneeded complexity (?)

Something like:

```<code>class Animal
{
  public static Animal CreateAnimal(string name)
  {
     switch(name)
     {
        case "Shark":
          return new SeaAnimal();
          break;
        case "Dog":
          return new LandAnimal();
          break;
        default:
          throw new Exception("unknown animal");
     }
  }
}
class LandAnimal : Animal
{
}

class SeaAnimal : Animal
{
}
</code>```

Body:
You could use Generics to avoid the switch statement and decouple the downstream implementations from the base class as well.:

 public static T CreateAnimal<T>() where T: new, Animal
 {
    return new T();
 }

Usage:

LandAnimal rabbit = Animal.CreateAnimal();  //Type inference should should just figure out the T by the return indicated.

or

 var rabbit = Animal.CreateAnimal<LandAnimal>();


问:
How to Mentor a Junior Developer
This title is a little broad but I may need to give a little background before I can ask my question properly.

I know that similar questions have been asked here already. But in my case I'm not asking if I should be mentoring someone or if the person is a good fit for being a software developer. That is not my place to judge. I have not been asked outright, but it is apparent that myself and other fellow senior developers are to mentor the new developers that start here. I have no problem with this whatsoever and, in many cases, it lends me a fresh perspective on things and I end up learning in the process. Also, I remember how beneficial it was in the beginning of my career when someone would take some time to teach me something.

When I say "new developer" they could be anywhere from fresh out of college to having a year or two of experience.

Recently we've had people start here who seem to have an attitude toward development/programming which is different from my own and hard for me to reconcile; they extract just enough information to get the task done but not really learn from it. I find myself going over and over the same issues with them. I understand that part of this could be a personality thing, but I feel it's my job to do my best and push them out of the nest while they're under my wing, so to speak.

How can I impart just enough information so that they will learn but not give so much as to solve the problem for them?

Or perhaps:

What's the proper response to questions that are designed to take the path of least resistance and, in essence, force them to learn instead of take the easy way out?

These questions are probably more general teaching questions and don't have that much to do specifically with software development.

Note: I do not get a say in what tasks they are working on. Management doles the task out and it could be anything from a very simple bug fix to starting an entire application by themselves. While this is not ideal by any means and obviously presents its own gauntlet of challenges, I feel it's a topic best left for another question. So the best I can do is help them with the problem at hand and try to help them break it down into simpler problems and also check their commit logs and point out mistakes that they made.

My main objectives are to:

Help them out and give them the tools they need to start becoming more self-reliant.

Steer them in the right direction and break bad development habits early on.

Lessen the amount of time I spend with them (the personality type described above tends to need much more one-on-one time and does not do well over IM or email. While that's generally fine, I can't always stop what I'm working on, break my stride, and help them debug an error on a moments notice; I have my own projects that need to get done).

答:
I, as a junior developer feel that if I come across an issue would be better put getting the answer straight away and spending time understanding how it was solved.

Im paid. my employer doesnt expect to pay me for learning. im expected to do a job at the end of the day. No point wasting time in a working enviroment try to discover a solution. Thats something I will pick up in time, hopefully quickly if im any good at what I do.

Title: How to Mentor a Junior Developer


答:
I'm a junior developer and I think that my mentor deals with these things very well. Generally, he will tell me a couple of ways to do something, but not how to do it. Then I used to sit there and try out both ways, and decide which was the cleanest solution to the problem.

Also, if ever he was doing something that might be useful to me, he would call me over just to give a walk through of what he was doing and why.

This resulted in a small amount of time being spent with me and essentially meaning that I had to myself learn the right answers and how to implement things. Of course, if I ever get stuck he'd be there to help out but this was a handful of times. After only 5 months working with him I probably gained more knowledge of things than the whole of my university course.

The important thing to remember is that I am just an individual and this worked well for me because of how I am and how he is. It is about finding a suitable structure that will help both of you.

Title: How to Mentor a Junior Developer

Body:
This title is a little broad but I may need to give a little background before I can ask my question properly.

I know that similar questions have been asked here already. But in my case I'm not asking if I should be mentoring someone or if the person is a good fit for being a software developer. That is not my place to judge. I have not been asked outright, but it is apparent that myself and other fellow senior developers are to mentor the new developers that start here. I have no problem with this whatsoever and, in many cases, it lends me a fresh perspective on things and I end up learning in the process. Also, I remember how beneficial it was in the beginning of my career when someone would take some time to teach me something.

When I say "new developer" they could be anywhere from fresh out of college to having a year or two of experience.

Recently we've had people start here who seem to have an attitude toward development/programming which is different from my own and hard for me to reconcile; they extract just enough information to get the task done but not really learn from it. I find myself going over and over the same issues with them. I understand that part of this could be a personality thing, but I feel it's my job to do my best and push them out of the nest while they're under my wing, so to speak.

How can I impart just enough information so that they will learn but not give so much as to solve the problem for them?

Or perhaps:

What's the proper response to questions that are designed to take the path of least resistance and, in essence, force them to learn instead of take the easy way out?

These questions are probably more general teaching questions and don't have that much to do specifically with software development.

Note: I do not get a say in what tasks they are working on. Management doles the task out and it could be anything from a very simple bug fix to starting an entire application by themselves. While this is not ideal by any means and obviously presents its own gauntlet of challenges, I feel it's a topic best left for another question. So the best I can do is help them with the problem at hand and try to help them break it down into simpler problems and also check their commit logs and point out mistakes that they made.

My main objectives are to:

Help them out and give them the tools they need to start becoming more self-reliant.

Steer them in the right direction and break bad development habits early on.

Lessen the amount of time I spend with them (the personality type described above tends to need much more one-on-one time and does not do well over IM or email. While that's generally fine, I can't always stop what I'm working on, break my stride, and help them debug an error on a moments notice; I have my own projects that need to get done).