答:
In the Lisp world, it is quite common to see the code which writes code which writes code (and so on). So, any decently sized Lisp or Scheme project will serve as a good code example. I'd recommend looking at the Racket compiler and runtime sources, as well as Bigloo, their libraries are just brilliant.

As for the productivity: I'm using metaprogramming as a dominant technique in almost all of my development work, and it clearly helps a lot, both reducing the code size and increasing its readability. The key is in using Domain Specific Languages, and metaprogramming is one of the most efficient ways of implementing them.


问:
Performance vs. Laziness: Why use setters from within a class?
I notice that web related code uses setter methods to set class fields instead of setting them directly since they are in scope.  I find this to be a bit odd.  Using setters is certainly safer, but if unit tests are implemented then bugs will be found.  And it's not worth the extra stack call, imo.

Does any production code do this or is this just what you see in sample code online?

Edit:  I have to make clear that I'm only talking about the case whereby the setter consists solely of a single assignment expression and nothing more.

答:
You should follow the open/closed principle. Not using the setter means your class is not open to extension, because subclasses overriding the setter to maintain internal consistency by adding some according logic within the call will not have that logic executed and thus wind up with an inconsistent state.

As opposed to that, the argument with the extra call is virtually void.

Either the setter is overriden in a subclass, which means not using it is strictly not an option. Or the setter is not overriden, in which case any decent (JIT) optimizer will be able to inline it and thus achieve the same performance.

ContentLicense: CC BY-SA 3.0


问:
What are the steps in beginning a large project, when all I have is a big idea?
I am computer engineering student. I've been thinking about
how I can handle a big project. What should be my first step to reach my goal in a more efficient and effective way?

When I come up with a project, I don't know how I should start working on it. Many times, I just ignore it. However, I don't want to ignore my project ideas anymore.

Now, I am asking to all of you, can anyone share his/her experiences? How should I start a project when all I have is an idea?

答:
I think something a lot of these answers don't touch on is getting something tangible done, and forcing yourself to get it done.

Sometimes you get stuck in 'thinking land' where you feel like all that's left is the tedium of typing things out ,but actually start on a bite sized chunk of your project and the implementation is both fun and challenging.

I know a lot of people who are like this, including me, until I actually get going I get nothing done, I can't -just- think and plan to start a project. I have to pick a piece that I can readily implement, and get to it and then the flow starts.


问:
Is it acceptable to deploy web app to production directly from SVN
Question

Is there a legitimate reason NOT to use SVN for production deploys, or is this merely a case of personal preference and there is no real case against SVN?

Background

My workplace has a culture of tagging release in SVN and then deploying those releases directly to the various web servers using svn co or svn switch including directly to production.

I personally have a problem with this as I believe that without using a build and deploy script or some form or automated deploy you lose integration environment settings as they're undocumented.  However more than that I have a gut feeling that there may be a hidden danger to doing that which has been overlooked, something which has yet to rear its ugly head.

I've brought up my concerns with the operations staff who are responsible for deploying code to our various environments (staging, pre-prod, production) etc.  Their arguments were pretty much that it's worked pretty well so far, no reason to change.

Edit:

What I mean about build and deploy:

For example, if a developer requires a web.config setting added for a particular environment. Web.config is generally not kept in svn and so these files are updated manually without any form of automated build script. So if they're lost or OPS forget to add a field to the web.config for a release then you have issues.

A build script that say uses XMLPoke to automatically generate a web.config appropriate for a particular environment is ideal in that you have a versionable script which documents all changes necessary for each of your environments.

Current Build and Deploy Method

For the project in question a developer builds a release manually, other projects have the build step automated either with NANT, or MSBuild which is OK.

Database migrations for most projects are via DB scripts, or migration scripts (Migrator.NET), or CMS Packages.

CI is usually done by Team City on a per checkin basis, we have a code review process that all tickets are done in branches and then peer reviewed for validation and correctness/quality prior to checking into trunk (works well).

However actual code deploy is pretty much always via SVN, either via a checkout of a tagged release or more generally an SVN Switch.  This is something that sticks odd with me that we're using our repository as part of the deploy process.

Configuration doesn't generally change very often, the only things that will be in config files are environment specific information.  Everything else is in the db.

Don't get me wrong this works, it works well.  However I want to try and push for an automated build and deploy.  I've used this with Rails and Capistrano, and for personal projects using Cygwin, Nant and SSH.

More importantly I would need very specific valid arguments to get my colleagues to change to using an Automated build and deploy.

Or are there NO real valid arguments against using SVN specifically to deploy to production?

答:
From my experience, there are both advantages and disadvantages:

Pros:

Sometimes you make urgent hot fixes on the production server, then you can check them back in directly from there. (Although theoretically, for security reasons it's always a good idea to use read-only access to the repo from the production server.)

Simplicity: you deliver quickly, although as others mentioned here, switching to an update-script scheme can be as easy.

Cons:

Your system can become unstable during your svn up and DB updates. For a high-traffic site this means some users will hit error messages, broken pages or empty pages at best. Well, that's what we very often see on various social services. A good service, however, does it "atomically" in a sense that it puts the system into maintenance mode for the duration of an update. (You broke reddit!)

Conflicts: resolving sudden conflicts on the productions server is a terrible idea: again, the service becomes unstable while you're fixing it.

Unrelated files on the production server which may or may not belong to you, although of course you can avoid it by checking out the right subtree in the repo.

Security: someone who gained access to your production server, legitimately or not, also gains access to your repos, possibly other products as well, and possibly also with write access! Overall opening up your internal SVN server to the outside world is a bad idea. Your source repositories should be behind a company firewall, period.

There are going to be update scripts anyway, e.g. for updating the DB structure, managing cronjobs, etc, so why not having a script that does it all? - i.e. pulls the latest pre-packaged release, switches to maintenance mode, updates sources, runs release-specific scripts etc.

Edit: for those still on the SVN scheme, don't forget this in your apache config:

```<code><DirectoryMatch .svn>
    Order deny,allow
    Deny from all
</DirectoryMatch>
</code>```

Body:
From my experience, there are both advantages and disadvantages:

Pros:

Sometimes you make urgent hot fixes on the production server, then you can check them back in directly from there. (Although theoretically, for security reasons it's always a good idea to use read-only access to the repo from the production server.)

Simplicity: you deliver quickly, although as others mentioned here, switching to an update-script scheme can be as easy.

Cons:

Your system can become unstable during your svn up and DB updates. For a high-traffic site this means some users will hit error messages, broken pages or empty pages at best. Well, that's what we very often see on various social services. A good service, however, does it "atomically" in a sense that it puts the system into maintenance mode for the duration of an update. (You broke reddit!)

Conflicts: resolving sudden conflicts on the productions server is a terrible idea: again, the service becomes unstable while you're fixing it.

Unrelated files on the production server which may or may not belong to you, although of course you can avoid it by checking out the right subtree in the repo.

Security: someone who gained access to your production server, legitimately or not, also gains access to your repos, possibly other products as well, and possibly also with write access! Overall opening up your internal SVN server to the outside world is a bad idea. Your source repositories should be behind a company firewall, period.

There are going to be update scripts anyway, e.g. for updating the DB structure, managing cronjobs, etc, so why not having a script that does it all? - i.e. pulls the latest pre-packaged release, switches to maintenance mode, updates sources, runs release-specific scripts etc.

Edit: for those still on the SVN scheme, don't forget this in your apache config:

<DirectoryMatch .svn>
    Order deny,allow
    Deny from all
</DirectoryMatch>


答:
The very first thing you need to do is sit down and describe that idea in writing. It will not become a project until then, and even then, you have some work to take it from being something as ephemeral as an idea to something as tangible as a project.

Once you have gotten that far, you can start looking at turning it into a project, identifying how you might break it down into discrete steps which can be implemented in a logical manner.

Then outline a timeline for implementing those steps. Revisit progress at given intervals so that you retain some control of that process - rather than having creeping ideas you never thought of in the first place and adding them to the mix.

Identify an initial finish line and aim for that. The less you adhere to that, the more the project is likely to sink beneath the weight of additional ideas, and the more discouraged you may get about completing it as it seems to live forever.

Title: What are the steps in beginning a large project, when all I have is a big idea?

Body:
I am computer engineering student. I've been thinking about
how I can handle a big project. What should be my first step to reach my goal in a more efficient and effective way?

When I come up with a project, I don't know how I should start working on it. Many times, I just ignore it. However, I don't want to ignore my project ideas anymore.

Now, I am asking to all of you, can anyone share his/her experiences? How should I start a project when all I have is an idea?


问:
How large non-OO code bases are managed?
I always see abstraction is a very useful feature the OO provides for managing the code-base. But how are large non-OO code bases are managed? Or do those just become a "Big Ball of Mud" eventually?

Update:

It seemed everyone is thinking 'abstraction' is just modularization or data-hiding. But IMHO, it also means the use of 'Abstract Classes' or 'Interfaces' which is a must for dependency-injection and thus testing. How non-OO code bases manage this? And also, other than abstraction, the encapsulation also helps a lot to manage large code bases as it define and restrict the relation between data and functions.

With C, it is very much possible to write pseudo-OO code. I don't know much about other non-OO languages. So, is it THE way to manage large C code bases?

答:
Actually, as you recently have discovered, first order functions are all you need for dependency inversion.

C supports first order functions and even closures to some extent. And C macros are a powerful feature for generic programming, if handled with necessary care.

It's all there. SGLIB is quite a good example on how C can be used to write highly reusable code. And I believe there's a lot more out there.


问:
Website Planning Help
There are a lot of posts on this but I'm kinda looking for specific help, I've typed many different queries into Google but the majority of page returns seem to be dominated by beginner tutorials, planning, generators, and lots of other rubbish related information, It may have something to do with that fact that I'm rubbish at searching for content on search engines, but that's besides the point!

I'm just about to endeavour on an adventure to create a pretty stylish looking, very functional, adaptable website.

But I don't want to miss anything out.

Its happened too many times where I've come up with an idea, planned, planned, designed, implemented, then realised I've missed something, or something's wrong and I've had to turn the website on its head in order to compensate. Im sure other people have had similar situations.

My Question is:

What is everything I need to consider before actually coding my website?

I'm talking from coding standard, implementation, design aspect,abstract point of view.

Currently, I have:

designed the look of the website.

Made storyboard like diagrams for every page, action, event.

invented content.

designed a style guide.

mapped animation.

modularised my functions.

considered audience.

considerend diversity (including cross-browser compatibility, screen resolution and font size)

created a nice directory

AND FINALLY...

have included my frameworks (css reset, jQuery, images, wordpress, etc)

Is There anything else?
What am I not considering?

I just wanted to make sure I've covered every aspect before I sit down (with my brand new coffee machine) and code like a fairy on crack.

If anybody has come across any worthy articles... Please share.

But please, no "how to make a website" beginner articles. Purely in the context of the question.

Personal preferences and responses are preferred!

What planning/design steps do you take before embarking on a monster website mission?

Thank you for reading this long ASS boring question

Alex

答:
I think the question is the root of your problem.

Do you expect the software project as it is to run without a hitch? I guess not, you will have ways to deal with changes and what not.

Why would you then expect the managment of the project to run without a hitch? Change your approach to deal easily with missed items and mistakes.

Title: Website Planning Help


问:
When would someone be considered a bad programmer?
How would you consider that a programmer is bad at what he or she is doing?

If possible... How should he/she improve?

答: Today, many programmers believe that this complexity is best managed by using only a small set of well-understood techniques in their programs. They have composed strict rules about the form programs should have, and the more zealous among them will denounce those who break these rules as bad programmers</p>

ContentLicense: CC BY-SA 2.5


答:
When working in languages which lack inbuilt structure and organisation features (e.g. if it doesn't have namespaces, packages, assemblies etc...) or where these are insufficient to keep a codebase of that size under control, the natural response is to develop our own strategies to organise the code.

This organisation strategy probably includes standards relating to where different files should be kept, things that need to happen before/after certain types of operations, and naming conventions and other coding standards, as well as a lot of "this is how it is set up - don't mess with it!" type comments - which are valid so long as they explain why!

Because the strategy is most likely going to end up being tailored to the specific needs of the project (people, technologies, environment etc...) it is hard to give a one-size-fits-all solution to managing large code bases.

Therefore I believe the best advice is to embrace the project-specific strategy, and make managing it a key priority: document the structure, why it is that way, the processes for making changes, audit it to make sure it is being adhered to, and crucially: change it when it needs to change.

We are mostly familiar with refactoring classes and methods, but with a large codebase in such a language it is the organising strategy itself (complete with documentation) that needs to be refactored as and when necessary.

The reasoning is the same as for refactoring: you will develop a mental block towards working on small parts of the system if you feel that the overall organisation of it is a mess, and will eventually allow it to deteriorate (at least that's my take on it).

The caveats are also the same: use regression testing, make sure you can easily revert if the refactoring goes wrong, and design so to facilitate refactoring in the first place (or you just won't do it!).

I agree that is is much trickier than refactoring direct code, and it is harder to validate/conceal the time from managers/clients who might not understand why it needs to be done, but these are also the types of project most prone to software rot caused by inflexible top-level designs...

Title: How large non-OO code bases are managed?

Body:
I always see abstraction is a very useful feature the OO provides for managing the code-base. But how are large non-OO code bases are managed? Or do those just become a "Big Ball of Mud" eventually?

Update:

It seemed everyone is thinking 'abstraction' is just modularization or data-hiding. But IMHO, it also means the use of 'Abstract Classes' or 'Interfaces' which is a must for dependency-injection and thus testing. How non-OO code bases manage this? And also, other than abstraction, the encapsulation also helps a lot to manage large code bases as it define and restrict the relation between data and functions.

With C, it is very much possible to write pseudo-OO code. I don't know much about other non-OO languages. So, is it THE way to manage large C code bases?


问:
Developers Terms and Conditions
I've recently been approached to do some development work for a start up.

The fellow has requested my terms and conditions.

Being new to the industry, what sort of information would/should I include in this?

Obviously pay rate and maybe information about ownership of Intellectual Property perhaps.

Is there anything I'm missing?

答: Considering your comment (being 21), you should make it clear that you'll bill by hours worked, with a "best effort" commitment only. You simply won't have the experience to make a proper "fixed cost" offer. The "Consultancy for Dummies" book (or similar titles) are sufficient for such simple contracts. You're just selling hours worked, so it's similar to being a gardener. You don't need to address special software-specific considerations.</p>

Title: Developers Terms and Conditions


问:
Quality vs Time
I have heard of developers who work with code which is a complete mess because originally the code was quickly developed and the quality was not there in the first place.

Its always good to get maintainable, reusable code but I was wondering if it was best to sacrifice some of this due to time constraints. A common problem I come up against is over engineering something and wasting a lot of time. We all know in the real world due to time constraints its going to be very difficult to get near perfect code.

I was wondering if there was a general rule for getting good quality if there is not much development time? Do you find this a common problem in development balancing code quality and time?

答:
Time and quality are mostly orthogonal. Certainly, you get poor quality if you rush through an implementation, and better quality if you have plenty of time for implementation, testing, and polishing. But just spending a long time doesn't ensure good quality, and getting a task done quickly doesn't necessarily mean that it was rushed or that the solution is of poor quality.

The thing that links time and quality is complexity. Generally, the more complex a system the longer it takes to implement, the harder it is to verify, and the higher its rate of defects. Simpler solutions are easier to understand, faster and easier to implement correctly, likely to have a lower rate of defects (i.e. higher quality). The simple solution isn't always the obvious one; it often takes more time up front to create a simpler design, but that time is usually well spent and pays dividends in quality and development time later.

Title: Quality vs Time


问:
What do programmers have to know about business/management?
As I've implied through my other posts, I'm still fairly new to the workforce. During team meetings, I tend to be able to keep up with technical discussion, but when my project manager starts talking about how we've won a new contract, or we're involved in a new proposal bid, or... anything that's business rather than technical, really... I can get lost pretty quickly.

What is the bare minimum all developers need to know about project management/business to function?

答:
What is the bare minimum all developers need to know about project management/business to function?

"...good technology is only 10% of success. If your management doesn't know how to manage a successful engineering project, or your marketing department doesn't know how to access the customers, or doesn't tell you what the customer wants, or if your lawyers don't handle your intellectual property correctly, or if the chief architect doesn't have the ability to create a consistent and simple architecture, then your work can be for naught, and you can spend years building things that never see the light of day."  (The Things I Wish I Learned in Engineering School...)


问:
Why is DRY important?
Quite simple, why would I want to write code that works for all cases and scalable data when all I need to do is repeat the same process a few times with a few minor tweaks?

I'm unlikely to need to edit this again any time soon.

It looks like a lot of less work to just go...

```<code>function doStuff1(){/*.a.*/}
function doStuff2(){/*.b.*/}
function doStuff3(){/*.c.*/}
</code>```

And if I ever need to add something...

```<code>function doStuff4(){/*.d.*/}
</code>```

And if I need to remove it, I remove it.

It's harder to figure out how to make all of those into one straight-forward pattern that I can just feed data into and deal with all the cases, and make a bunch of changes I don't feel like I'm ever going to have to do.

Why be DRY when it looks like a quick cut+paste is going to be so much less work?

答:
There is such a thing as too much DRY. When this happens, two concepts which appear at some point to be similar enough to warrant factoring code (1) may later turn out to be different enough that they deserve separate implementations.

In other words, DRY and loose coupling sometimes conflict. If you expect doStuff1 and friends to diverge with every new release of the software, it's OK to duplicate their code.

In my experience, it can be difficult to judge where your software is going in the future, and for this reason, DRY is often a safe choice.

Code that has been overly "dried" typically has complex control flow and too many parameters. What was initially a simple function was later extended to support a new functionality controlled by an extra parameter. After two or three iterations, the function is no longer maintainable. Fix a bug that occurs in a setting, and you introduce new bugs in other settings.

It's understandable that code quality often goes down as code evolves, but I've seen cases where a multi-parameter function with if-then-else spaghetti in the body was the result of a well-meaning but poorly conducted refactoring effort.

(1) I'm using the word "code", but this applies to design as well.

Title: Why is DRY important?


答:
It seems to me that the less time you have for coding, it is likely that there are even more worrying cuts in testing time which will almost certainly have a knock on on quality. </p>

<p>Additionally, if you are short on time, your best bet for getting good clean code (as far as is possible) is in a) having good clean clear and non-ambiguous requirements and a code base which is already reasonably clean so that the discipline is already in place. Unfortunately, very few ideal worlds exist. </p>

Title: Quality vs Time

Body:
I have heard of developers who work with code which is a complete mess because originally the code was quickly developed and the quality was not there in the first place.

Its always good to get maintainable, reusable code but I was wondering if it was best to sacrifice some of this due to time constraints. A common problem I come up against is over engineering something and wasting a lot of time. We all know in the real world due to time constraints its going to be very difficult to get near perfect code.

I was wondering if there was a general rule for getting good quality if there is not much development time? Do you find this a common problem in development balancing code quality and time?

Body:
It seems to me that the less time you have for coding, it is likely that there are even more worrying cuts in testing time which will almost certainly have a knock on on quality.

Additionally, if you are short on time, your best bet for getting good clean code (as far as is possible) is in a) having good clean clear and non-ambiguous requirements and a code base which is already reasonably clean so that the discipline is already in place. Unfortunately, very few ideal worlds exist.


问:
How to implement DRY principle when using 'using' keyword?
Consider these methods:

```<code>public List<Employee> GetAllEmployees()
{
    using (Entities entities = new Entities())
    {
        return entities.Employees.ToList();
    }
}

public List<Job> GetAllJobs()
{
    using (Entities entities = new Entities())
    {
        return entities.Jobs.ToList();
    }
}

public List<Task> GetAllTasksOfTheJob(Job job)
{
    using (Entities entities = new Entities())
    {
        return entities.Tasks.Where(t => t.JobId == job.Id).ToList();
    }
}
</code>```

Using block is the same and has been repeated 3 times here (of course, more than 100 times in the real application). How is it possible to implement DRY (Don't Repeat Yourself) principal for using block? Is it considered a breach of DRY principal at all?

Update: I'm not talking about what has been implemented inside the using block. What I actually mean here, is the using (Entities entities = new Entities()). This line is repeated 100 times or more.

答:
Since there is no business logic of any sort here except for the last one. Its not really DRY, in my view.

The last one doesnt have any DRY in the using block but I guess the where clause should change where ever it used.

This is a typical job for code generators. Write and cover code generator and let it generate for each type.


问:
What is the most orthogonal programming language?
I find myself repeatedly annoyed by having to teach freshmen about special language rules (like array-to-pointer decay) that have absolutely nothing to do with programming in itself. So I wondered:

What is the programming language with the smallest number of special language rules, where everything is first class and can be composed without annoying technical restrictions? Wouldn't such a language be the perfect teaching language?

Moderator Note

We're looking for long answers that provide some explanation and context. Don't just list a language: please explain why you think the language answers the question. Answers that don't explain anything will be deleted. See Good Subjective, Bad Subjective for more information.

答:
Whatever the choice, I would strongly urge teaching a “real” language. Teaching toy languages works for some people, but for others it’s very, very frustrating due to the disconnect to the real world. Some people need real-world relevance as a motivation for learning, and it’s not our place to judge this learning strategy (in fact, that’s a common misconception).

This disqualifies languages such as Logo, but also domain-specific languages such as Processing. While the latter is extremely useful for certain things (e.g. producing info graphics), the use is too restricted for most uses (and thus most users). This also excludes Gofer, a useless Haskell subset. It also excludes Pascal because although the latter has been used in real projects, it just isn’t relevant any more and simply lacks essential features (e.g. built-in strings).

Of the practical languages, I’d agree with those already mentioned: modern Lisp or Scheme dialects, Haskell, Python or Ruby. Personally, I’d probably use Python but all those choices have their share of advantages and disadvantages.


答:
I fail to see the use of using here:

How about:

```<code>public List<Employee> GetAllEmployees() {
    return (new Entities()).Employees.ToList();
}
public List<Job> GetAllJobs() {
    return (new Entities()).Jobs.ToList();
}
public List<Task> GetAllTasksOfTheJob(Job job) {
    return (new Entities()).Tasks.Where(t => t.JobId == job.Id).ToList();
}
</code>```

Or even better, as I don't think you need to create a new object every time.

```<code>private Entities entities = new Entities();//not sure C# allows for that kind of initialization, but you can do it in the constructor if needed

public List<Employee> GetAllEmployees() {
    return entities.Employees.ToList();
}
public List<Job> GetAllJobs() {
    return entities.Jobs.ToList();
}
public List<Task> GetAllTasksOfTheJob(Job job) {
    return entities.Tasks.Where(t => t.JobId == job.Id).ToList();
}
</code>```

As for breaching DRY: DRY doesn't apply on this level. In fact no principle really does, except that of readability. Trying to apply DRY at that level is really just architectural micro-optimization, which like all micro-optimization is just bike-shedding and doesn't get any problems solved, but even risks to introduce new ones.

From my own experience, I know that if you try to reduce code redundancy at that level, you create a negative impact on code quality, by obfuscating what was really clear and simple.

Edit:

Ok. So the problem is not actually the using statement, the problem is the dependency on the object you create every time. I would suggest injecting a constructor:

```<code>private delegate Entities query();//this should be injected from the outside (upon construction for example)
public List<Employee> GetAllEmployees() {
    using (var entities = query()) {//AFAIK C# can infer the type here
        return entities.Employees.ToList();
    }
}
//... and so on
</code>```

Title: How to implement DRY principle when using 'using' keyword?

Body:
Consider these methods:

```<code>public List<Employee> GetAllEmployees()
{
    using (Entities entities = new Entities())
    {
        return entities.Employees.ToList();
    }
}

public List<Job> GetAllJobs()
{
    using (Entities entities = new Entities())
    {
        return entities.Jobs.ToList();
    }
}

public List<Task> GetAllTasksOfTheJob(Job job)
{
    using (Entities entities = new Entities())
    {
        return entities.Tasks.Where(t => t.JobId == job.Id).ToList();
    }
}
</code>```

Using block is the same and has been repeated 3 times here (of course, more than 100 times in the real application). How is it possible to implement DRY (Don't Repeat Yourself) principal for using block? Is it considered a breach of DRY principal at all?

Update: I'm not talking about what has been implemented inside the using block. What I actually mean here, is the using (Entities entities = new Entities()). This line is repeated 100 times or more.

Body:
I fail to see the use of using here:

How about:

public List<Employee> GetAllEmployees() {
    return (new Entities()).Employees.ToList();
}
public List<Job> GetAllJobs() {
    return (new Entities()).Jobs.ToList();
}
public List<Task> GetAllTasksOfTheJob(Job job) {
    return (new Entities()).Tasks.Where(t => t.JobId == job.Id).ToList();
}

Or even better, as I don't think you need to create a new object every time.

private Entities entities = new Entities();//not sure C# allows for that kind of initialization, but you can do it in the constructor if needed

public List<Employee> GetAllEmployees() {
    return entities.Employees.ToList();
}
public List<Job> GetAllJobs() {
    return entities.Jobs.ToList();
}
public List<Task> GetAllTasksOfTheJob(Job job) {
    return entities.Tasks.Where(t => t.JobId == job.Id).ToList();
}

As for breaching DRY: DRY doesn't apply on this level. In fact no principle really does, except that of readability. Trying to apply DRY at that level is really just architectural micro-optimization, which like all micro-optimization is just bike-shedding and doesn't get any problems solved, but even risks to introduce new ones.

From my own experience, I know that if you try to reduce code redundancy at that level, you create a negative impact on code quality, by obfuscating what was really clear and simple.

Edit:

Ok. So the problem is not actually the using statement, the problem is the dependency on the object you create every time. I would suggest injecting a constructor:

private delegate Entities query();//this should be injected from the outside (upon construction for example)
public List<Employee> GetAllEmployees() {
    using (var entities = query()) {//AFAIK C# can infer the type here
        return entities.Employees.ToList();
    }
}
//... and so on


问:
Is the C programming language still used?
I am a C# programmer, and most of my development is for websites along with a few Windows applications. As far as C goes, I haven't used it in a long time, as there was no need to. It came to me as a surprise when one of my friends said that she needs to learn C for testing jobs, while I was helping her learn C#.

I figured that someone would only learn C for testing if there is development being done in C. From my knowledge, all development related to COM and hardware design is also done in C++. Therefore, learning C doesn't make sense if you need to use C++. I also don't believe in historic significance, so why waste time and money in learning C?

Is C still used in any kind of new software development or anything else?

答:
C is used a lot in embedded hardware programming where resources are scarce.

Linux kernel is written in C because, according to Linus Torvalds, C++ is a horrible language.

ContentLicense: CC BY-SA 4.0


问:
VB.Net vs C# debate
I've been in workplaces where, at the start of a project, the "Should we use VB.Net or C#" question has been raised.

Granted, it's probably less common to have to make that decision now than it was in the early days of .Net, particularly given the trend towards language convergence, but it can still be a heated debate.

So, between VB.Net and C#, Which language do you prefer and why?

答:
VB the language is easier to read for newbies, they tend to write their first, second and third application in it and we all know what our first applications are coded like - terribly.

Programmers from C++, Java and etc have moved to C# whilst VB.NET developers come from VBA, VB and BASIC background, essential non-traditional programmers.

Title: VB.Net vs C# debate


答:
You may need to use C when you are low on resources and don't need object oriented capabilities.

Many softwares in use today are still written in C, not to mention hardware drivers.

According to Tiobe index, C is still the most used language.

As tcrosley suggested, you may want to take a look at this related question.

You should also check for some related articles on the differences between C and C++, like this wiki or this for example.

Title: Is the C programming language still used?

Body:
I am a C# programmer, and most of my development is for websites along with a few Windows applications. As far as C goes, I haven't used it in a long time, as there was no need to. It came to me as a surprise when one of my friends said that she needs to learn C for testing jobs, while I was helping her learn C#.

I figured that someone would only learn C for testing if there is development being done in C. From my knowledge, all development related to COM and hardware design is also done in C++. Therefore, learning C doesn't make sense if you need to use C++. I also don't believe in historic significance, so why waste time and money in learning C?

Is C still used in any kind of new software development or anything else?


答:
C has the advantage that it is a relatively small language, which makes it easy to implement a C compiler (whereas a C++ compiler is a monster to write), and makes it easier to learn the language. Also see the TIOBE index, according to which C slightly ahead of C++.

In (IMO) decreasing order of justification, C is still used a lot for

Embedded stuff

It's way easier to port a C compiler to a small platform than it is to port a C++ compiler. Also, C advocates claim that C++ "does too much behind their backs". However, IMO that's FUD.

Systems programming

Again, that's usually due to claims that it is easier to "know what the compiler is doing". However, many embedded programs would benefit from, e.g., templates and other C++ key features.

Open source software

That's mostly an attitude problem, though: OSS has always preferred C over C++ (whereas it's the opposite in large parts of the industry). Torvalds' irrational hatred might actually be the most important reason for this on Linux.


问:
Should a competent programmer be able to come up with his own shortest path algorithm?
I'm suffering a crisis of confidence in my ability as a computer programmer.

Yesterday I tried to come up with my own shortest path algorithm for a graph and after some hours I simply threw in the towel and learned Dijkstra's algorithm.

Is this the kind of thing a good programmer should be able to "reinvent" in a couple of hours or am I being unrealistic?

Oh well, at least I was able to reinvent bubble sort :D

答:
A good programmer should realize that a great algorithm has already been written to solve a problem and doesn't waste time re-inventing wheels.

I doubt Dijkstra came up with the shortest path algorithm in a few hours, so that seems like a really high standard to use for determining if someone is a 'good programmer'


答:
It's very much unlikely that you will be able to find a better solution than the ones you can choose from.

Coming out with a better algorithm than one considered "the best" (in your case, the shortest) is no something everyone can do. Probably it's not even possible.

A good programmer should be able to understand the logic behind the algorithm, and why it's better or worse (or simply inadequate for that particular problem) than other algorithms which try to solve the same problem.

(s)He should be also able to know if it's really the best way to go for solving that particular problem.

Anyway if you want to practice, you can still try to write your personal implementation of an algorithm, trying to solve a problem using your mind. It may not be the best, but it's a good practice for problem solving.

Title: Should a competent programmer be able to come up with his own shortest path algorithm?

Body:
I'm suffering a crisis of confidence in my ability as a computer programmer.

Yesterday I tried to come up with my own shortest path algorithm for a graph and after some hours I simply threw in the towel and learned Dijkstra's algorithm.

Is this the kind of thing a good programmer should be able to "reinvent" in a couple of hours or am I being unrealistic?

Oh well, at least I was able to reinvent bubble sort :D


答:
Is this the kind of thing a good programmer should be able to "reinvent" in a couple of hours or am I being unrealistic?

Definitely unrealistic. People don't just "come up" with algorithms in a few hours. It takes a lot of effort and work. To quote this blog:

In Programming Pearls, Bentley, quoting Donald Knuth, says "While the first binary search was published in 1946, the first binary search that works correctly for all values of n did not appear until 1962."

and Bentley's version was also problematic when implemented for large sets.

Furthermore, a good programmer knows what tools are at his disposal and when to use those tools. You don't get extra points for originality or doing things differently - you want it to work and work well.


问:
Automatic programming: write code that writes code
After reading the book The Pragmatic Programmer, one of the arguments I found most interesting was "write code that writes code".

I tried searching over the net for some more explanations or articles about it, and while I found some good articles on the subject, I still haven't found any specific code implementation or good examples.

I feel it's still not a so common argument, something that lacks documentation or it's not embraced by so many people, and I would like to know more about it.

What do you think about the subject? Is it something that will really increase your productivity? What are some good resources on the subject, among books, blogs, slideshows, etc?

Some code examples would be greatly appreciated to allow me to better understand its implementation.

Here's the wiki page on the subject with various relevant programming techniques, like Meta Programming, Generative Programming and Code Generation.

答:
Most code writes code.  For example php code helps write html.  The php pdo library helps write SQL calls.  The file I/O functions write code to communicate with the OS.  Even a regular function call is a reference to another block of code which is executed.  So your functions calls are writing code.

In broad terms, we can think of computing as writing codes which write codes recursively forming a stack that terminates when it runs up against physical reality of codes wired into hardware.


问:
Why is C++ often the first language taught in college?
My school starts the computer science curriculum with C++ programming courses, meaning this is the first language that many of the students learn.

I've seen that many people dislike C++, and I've read a variety of reasons why.  It almost seems to be popular opinion that C++ isn't a very good language.  I get the impression it's not very liked based on some questions on StackExchange as well  as posts such as:

 http://damienkatz.net/2004/08/why-c-sucks.html

 http://blogs.kde.org/node/2298

 http://blogs.cio.com/esther_schindler/linus_torvalds_why_c_sucks

 http://www.dacris.com/blog/2010/02/16/why-c-sucks-part-2/

 etc.

(Note: It is not my opinion that C++ is a bad language.  In fact, it's the main language I use.  However, the internet as well as some professors have given me the impression that it's not a very widely liked language.  In fact, one of my professor constantly rags on C++, yet it's still the starting language at my college!)

With that in mind, why is this the first language taught at many schools? What are the reasons for starting a programming curriculum with C++?

Note: This question is similar to "Is C++ suitable as a first language", but is a little different since I'm not interested in whether it's suitable, but why it's been chosen.

答:
C/C++ is actually a better language than most others, firstly because it does not add a false sense of security. Secondly because you have tho know what you're doing.

I actually love the language, and I consider it superior to most alternatives.

It's also as productive as most other languages, and not that "crashy" if you know what you're doing, and think before you copy-pasta random codez.

Also a good read - http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html

However, some things in C++ are actually bad, for example exceptions, and unintuitive overhead in some cases. This is the reason, I guess, why Linus is so negative about it in the post you quoted.

A good read to touch one of the related topics - http://blogs.msdn.com/b/oldnewthing/archive/2004/04/22/118161.aspx


答:
In my opinion this is a very short sighted question akin to "My friends and I listen to Reggae. Does anybody really still listen to Rap?".

Every language out there has its use. Different languages definitely have their niches. But asking about C! I am sure fewer people use C# than C on a daily basis (from the totally biased view point of working in a shop where nobody uses C#).

Quick google looking on the relative popularity of languages.

I am sure none of this is authoritative but we can use it to see trends:

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

http://langpop.com/

Even looking at SO ratio of question on tags:

https://stackoverflow.com/tags

C#: 209845

16 other tags

C:   38790

So C is the 18 most popular topic on SO (and there are a lot of other languages there).

Note: The TIOBE index above has been constantly updated for over a decade (and has some data going back 3 decades) is supposed to measure engineers working in each language (though I have no idea how accurate that is). Of the top 10 languages except Java/Visual Basic it reflects what people in my shop know (though our ratios will be slightly different as we have a much smaller sample size).


答:
One of the classic examples is lex and yacc. Their primary purpose is to avoid the drudgery of writing any kind of parser. Along the way, they make it far faster to build complex parsers with many rules and states, and they also avoid all of surprise mistakes made by people rolling their own.

This is also the idea behind c, which is a tool to write assembler. The same thing goes for any high level language you care to name. For tools that write code for you, there are a few simple paradigms.

A proper IDE helps by providing documentation at your fingertips, smart auto completion, and code snippets. IDE's also include various templates, so you don't have to start a program from scratch. There are programs to take a uml diagram and rough out classes in a high level language.

Finally, you can write your own tools for code generation within your problem set. This is how lex and yacc first got started. Any kind of domain specific langauge exists for precisely this reason. You create some building blocks that describe your solution in easier to understand code, wrapping up common activities, or complicated sections with simple commands. You aren't looking for a solution to every problem, just an easier definition of the specific one you are dealing with.

In a sense, everything that you do above the binary layer is code automation.

Title: Automatic programming: write code that writes code

Body:
After reading the book The Pragmatic Programmer, one of the arguments I found most interesting was "write code that writes code".

I tried searching over the net for some more explanations or articles about it, and while I found some good articles on the subject, I still haven't found any specific code implementation or good examples.

I feel it's still not a so common argument, something that lacks documentation or it's not embraced by so many people, and I would like to know more about it.

What do you think about the subject? Is it something that will really increase your productivity? What are some good resources on the subject, among books, blogs, slideshows, etc?

Some code examples would be greatly appreciated to allow me to better understand its implementation.

Here's the wiki page on the subject with various relevant programming techniques, like Meta Programming, Generative Programming and Code Generation.


问:
Why and when should I make a class 'static'? What is the purpose of 'static' keyword on classes?
The static keyword on a member in many languages mean that you shouldn't create an instance of that class to be able to have access to that member. However, I don't see any justification to make an entire class static. Why and when should I make a class static?

What benefits do I get from making a class static? I mean, after declaring a static class, one should still declare all members which he/she wants to have access to without instantiation, as static too.

This means that for example, Math class could be declared normal (not static), without affecting how developers code. In other words, making a class static or normal is kind of transparent to developers.

答:
It makes it obvious to users how the class is used. For instance, it would be complete nonsense to write the following code:

```<code>Math m = new Math();
</code>```

C# doesn’t have to forbid this but since it serves no purpose, might as well tell the user that. Certain people (including me) adhere to the philosophy that programming languages (and APIs …) should be as restrictive as possible to make them hard to use wrong: the only allowed operations are then those that are meaningful and (hopefully) correct.

Body:
It makes it obvious to users how the class is used. For instance, it would be complete nonsense to write the following code:

Math m = new Math();

C# doesn’t have to forbid this but since it serves no purpose, might as well tell the user that. Certain people (including me) adhere to the philosophy that programming languages (and APIs …) should be as restrictive as possible to make them hard to use wrong: the only allowed operations are then those that are meaningful and (hopefully) correct.


答: To me this would be like worrying about foreach-ing over the same collection multiple times: it's just something that you need to do. Any attempt to abstract it further would make the code much less readable.</p>


答:
One idea would be to wrap it with a function that takes a Func.

Something like this

```<code>public K UsingT<T,K>(Func<T,K> f) where T:IDisposable,new()
{
    using (T t = new T())
    {
        return f(t);
    }
}
</code>```

Then your above code becomes

```<code>public List<Employee> GetAllEmployees()
{
    return UsingT<Entities,List<Employee>>(e=>e.Employees.ToList());
}

public List<Job> GetAllJobs()
{
    return UsingT<Entities,List<Job>>(e=>e.Jobs.ToList());
}

public List<Task> GetAllTasksOfTheJob(Job job)
{
    return UsingT<Entities,List<Task>>(e=>e.Tasks.Where(t => t.JobId == job.Id).ToList());
}
</code>```

I made Entities a type param too, because I'm assuming you have more than one type you're doing this with.  If you're not, you could remove it and just use the type param for the return type.

To be honest though this sort of code doesn't help readability at all.  In my experience the more Jr co-workers have a really tough time with it as well.

Update
Some additional variations on helpers you might consider

```<code>//forget the Entities type param
public T UsingEntities<T>(Func<Entities,T> f)
{
    using (Entities e = new Entities())
    {
        return f(e);
    }
}
//forget the Entities type param, and return an IList
public IList<T> ListFromEntities<T>(Func<Entities,IEnumerable<T>> f)
{
    using (Entities e = new Entities())
    {
        return f(e).ToList();
    }
}
//doing the .ToList() forces the results to enumerate before `e` gets disposed.
</code>```

Body:
One idea would be to wrap it with a function that takes a Func.

Something like this

public K UsingT<T,K>(Func<T,K> f) where T:IDisposable,new()
{
    using (T t = new T())
    {
        return f(t);
    }
}

Then your above code becomes

public List<Employee> GetAllEmployees()
{
    return UsingT<Entities,List<Employee>>(e=>e.Employees.ToList());
}

public List<Job> GetAllJobs()
{
    return UsingT<Entities,List<Job>>(e=>e.Jobs.ToList());
}

public List<Task> GetAllTasksOfTheJob(Job job)
{
    return UsingT<Entities,List<Task>>(e=>e.Tasks.Where(t => t.JobId == job.Id).ToList());
}

I made Entities a type param too, because I'm assuming you have more than one type you're doing this with.  If you're not, you could remove it and just use the type param for the return type.

To be honest though this sort of code doesn't help readability at all.  In my experience the more Jr co-workers have a really tough time with it as well.

Update
Some additional variations on helpers you might consider

//forget the Entities type param
public T UsingEntities<T>(Func<Entities,T> f)
{
    using (Entities e = new Entities())
    {
        return f(e);
    }
}
//forget the Entities type param, and return an IList
public IList<T> ListFromEntities<T>(Func<Entities,IEnumerable<T>> f)
{
    using (Entities e = new Entities())
    {
        return f(e).ToList();
    }
}
//doing the .ToList() forces the results to enumerate before `e` gets disposed.


答:
In addition to embedded systems, most newer languages have some way to interface with C. When writing a library that you want to have an easy time using in all of those languages, C is an obvious choice. C++, while it can also interface with some languages (such as Python (CPython only)), C++ cannot interface with a greater number of languages due to some of its features (name mangling especially, but templates don't help the issue). The C ABI is one of the easiest to interface with (I know you can write C++ and use extern "C" for the interface. I don't care).

It also has the benefit that C and C++ are really the best languages for systems programming and the C compile times are much faster. C++ compile times are noticeably the worst of any language I've used.

Now while there are other languages that want to become the popular systems language out there (I know about D in particular), a far majority of software is written in C/C++. Languages like D require someone to create a wrapper around the C library instead of just using it directly (like you would from C++).


答:
Is this the kind of thing a good programmer should be able to "reinvent" in a couple of hours or am I being unrealistic?

First, you are perhaps confusing programming with theoretical computer science. A fantastic programmer needs a good fundament in computer science but he doesn’t need to be fantastic. Dijkstra was fantastic at computer science.

Secondly, I would expect anybody with a sound understanding of graphs to develop their own graph traversal after a bit of thought. But not a shortest path algorithm. Dijkstra’s algorithm in particular is highly sophisticated. Once you understand it, it’s blindingly obvious. But most things are that way.

You could probably derive some kind of shortest path algorithm after trying out some stuff and giving the idea some time. But don’t be disappointed if that takes hours, or even a few days. This is completely OK and normal.

(Caveat: well, you should be able to brute force the problem in a few hours tops, but this wouldn’t yield a working algorithm even on fairly small graphs.)


问:
CSS remote contract
I am signing a contract with someone remote in another country in regards with creating a new style sheet for their website. In our agreement the client pays 1/3 of the money first as deposit and the rest will be paid when I show the completed project online to him.

Now my question is, since I know CSS is viewable online and there is no way to encode it, apart from the fact that I need to trust him, is there any way that I can protect my work from being stolen before the final payment?

How do theme developers usually work remotely?

I would appreciate if you please share your experiences with me

答:
Is there any way that I can protect my work from being stolen before
  the final payment?

If he pretends to look at the website containing the CSS (or have the CSS code at hand directly) no, you cannot protect it.

The CSS file will be downloaded by the browser. He will be able to look at it and copy it entirely if he wishes.

I really see no point in having a CSS being copied. I used CSS for years and there are really no magic tricks or something only you can accomplish. All the things you can do with CSS can be freely available online somewhere.

The same applies for your HTML code and JS (though you can obfuscate your scripts, but the code will still be available to others).

The most you can do is minify your CSS to make it "harder" to read.

You may want to sign a contract with him which states this is your own work and cannot be copied or reused, etc., and appending a copyright notice on the top of your files.

OwnerDisplayName: SwissChocolate

Title: CSS remote contract


答:
StackOverflow has a great discussion on this topic.  For ease of reference, I'll copy and paste it here, on behalf of its author, Mark S. Rasmussen:

I wrote my thoughts of static classes in an earlier thread:

I used to love utility classes filled up with static methods. They
  made a great consolidation of helper methods that would otherwise lie
  around causing redundancy and maintenance hell. They're very easy to
  use, no instantiation, no disposal, just fire'n'forget. I guess this
  was my first unwitting attempt at creating a service oriented
  architecture - lots of stateless services that just did their job and
  nothing else. As a system grows however, dragons be coming.

Polymorphism

Say we have the method UtilityClass.SomeMethod that happily buzzes
  along. Suddenly we need to change the functionality slightly. Most of
  the functionality is the same, but we have to change a couple of parts
  nonetheless. Had it not been a static method, we could make a derivate
  class and change the method contents as needed. As it's a static
  method, we can't. Sure, if we just need to add functionality either
  before or after the old method, we can create a new class and call the
  old one inside of it - but that's just gross.

Interface woes

Static methods cannot be defined through interfaces for logic reasons.
  And since we can't override static methods, static classes are useless
  when we need to pass them around by their interface. This renders us
  unable to use static classes as part of a strategy pattern. We might
  patch some issues up by passing delegates instead of interfaces.

Testing

This basically goes hand in hand with the interface woes mentioned
  above. As our ability of interchanging implementations is very
  limited, we'll also have trouble replacing production code with test
  code. Again, we can wrap them up but it'll require us to change large
  parts of our code just to be able to accept wrappers instead of the
  actual objects.

Fosters blobs

As static methods are usually used as utility methods and utility
  methods usually will have different purposes, we'll quickly end up
  with a large class filled up with non-coherent functionality -
  ideally, each class should have a single purpose within the system.
  I'd much rather have a five times the classes as long as their
  purposes are well defined.

Parameter creep

To begin with, that little cute and innocent static method might take
  a single parameter. As functionality grows, a couple of new parameters
  are added. Soon further parameters are added that are optional, so we
  create overloads of the method (or just add default values, in
  languages that support them). Before long, we have a method that takes
  10 parameters. Only the first three are really required, parameters
  4-7 are optional. But if parameter 6 is specified, 7-9 are required to
  be filled in as well... Had we created a class with the single purpose
  of doing what this static method did, we could solve this by taking in
  the required parameters in the constructor, and allowing the user to
  set optional values through properties, or methods to set multiple
  interdependent values at the same time. Also, if a method has grown to
  this amount of complexity, it most likely needs to be in its own class
  anyways.

Demanding consumers to create an instance of classes for no reason

One of the most common arguments is, why demand that consumers of our
  class create an instance for invoking this single method, while having
  no use for the instance afterwards? Creating an instance of a class is
  a very very cheap operation in most languages, so speed is not an
  issue. Adding an extra line of code to the consumer is a low cost for
  laying the foundation of a much more maintainable solution in the
  future. And finally, if you want to avoid creating instances, simply
  create a singleton wrapper of your class that allows for easy reuse -
  although this does make the requirement that your class is stateless.
  If it's not stateless, you can still create static wrapper methods
  that handle everything, while still giving you all the benefits in the
  long run. Finally, you could also make a class that hides the
  instantiation as if it was a singleton: MyWrapper.Instance is a
  property that just returns new MyClass();

Only a Sith deals in absolutes

Of course, there are exceptions to my dislike of static methods. True
  utility classes that do not pose any risk to bloat are excellent cases
  for static methods - System.Convert as an example. If your project is
  a one-off with no requirements for future maintenance, the overall
  architecture really isn't very important - static or non static,
  doesn't really matter - development speed does, however.

Standards, standards, standards!

Using instance methods does not inhibit you from also using static
  methods, and vice versa. As long as there's reasoning behind the
  differentiation and it's standardised. There's nothing worse than
  looking over a business layer sprawling with different implementation
  methods.

Title: Why and when should I make a class 'static'? What is the purpose of 'static' keyword on classes?

Body:
The static keyword on a member in many languages mean that you shouldn't create an instance of that class to be able to have access to that member. However, I don't see any justification to make an entire class static. Why and when should I make a class static?

What benefits do I get from making a class static? I mean, after declaring a static class, one should still declare all members which he/she wants to have access to without instantiation, as static too.

This means that for example, Math class could be declared normal (not static), without affecting how developers code. In other words, making a class static or normal is kind of transparent to developers.


答:
I think your points are ok, but you should make some considerations.

First of all, before thinking about anything, you should consider the most important aspect of your website: audience.

When you have the audience, you can then define another really important aspect: What the audience wants or expect from your website. Or perhaps what kind of content you want to deliver to them.

Those two aspect are critical.

Once you set those two points, you have to think about the functionalities your website needs: is it a static website? does it needs to work with a database to store user data? user interactions? AJAX?

When you have this in mind, you can think about which technologies to use: HTML or XML? Which server language and database? Which server?

Next step: actually start to design your website. Take a paper and a pen, or your preferred software and start to draw some tables and schemas. Where should I put the login and registration? What users expect to see when they first land on my home page? Is the navigation easy to access and immediate? Try to make the user interface look as clear as possible, the content easy to access and the users will be happy. Also, try to avoid too much fancy stuff.

When you have the picture, you can start coding.

These are my personal steps, and it's been pretty good until now.

Title: Website Planning Help

Body:
There are a lot of posts on this but I'm kinda looking for specific help, I've typed many different queries into Google but the majority of page returns seem to be dominated by beginner tutorials, planning, generators, and lots of other rubbish related information, It may have something to do with that fact that I'm rubbish at searching for content on search engines, but that's besides the point!

I'm just about to endeavour on an adventure to create a pretty stylish looking, very functional, adaptable website.

But I don't want to miss anything out.

Its happened too many times where I've come up with an idea, planned, planned, designed, implemented, then realised I've missed something, or something's wrong and I've had to turn the website on its head in order to compensate. Im sure other people have had similar situations.

My Question is:

What is everything I need to consider before actually coding my website?

I'm talking from coding standard, implementation, design aspect,abstract point of view.

Currently, I have:

designed the look of the website.

Made storyboard like diagrams for every page, action, event.

invented content.

designed a style guide.

mapped animation.

modularised my functions.

considered audience.

considerend diversity (including cross-browser compatibility, screen resolution and font size)

created a nice directory

AND FINALLY...

have included my frameworks (css reset, jQuery, images, wordpress, etc)

Is There anything else?
What am I not considering?

I just wanted to make sure I've covered every aspect before I sit down (with my brand new coffee machine) and code like a fairy on crack.

If anybody has come across any worthy articles... Please share.

But please, no "how to make a website" beginner articles. Purely in the context of the question.

Personal preferences and responses are preferred!

What planning/design steps do you take before embarking on a monster website mission?

Thank you for reading this long ASS boring question

Alex


答:
You're not going to notice the same things that everyone else does. I think that's just a fact of life that we have to live with. Much of it comes down to your passive learning and the mental models that you've developed as a result of them.

I know some very intelligent and competent programmers who had to be taught DeMorgan's law at school before they could do it consistently. I happened to figure out Dijkstra's Algorithm on my own (and I have to admit I'm a bit proud of it), but it took me a really long time until I could even understand bubble sort.

More famously, Einstein, who you'd think would be an expert in knot theory, couldn't tie his own shoelaces until he was around ten years old.

Chances are good that you've unknowingly reinvented many things that many others would have never figured out had it not been for them being taught explicitly.


答: Show screen shots only.  Send the style sheet when he pays.</p>

Title: CSS remote contract

Body:
I am signing a contract with someone remote in another country in regards with creating a new style sheet for their website. In our agreement the client pays 1/3 of the money first as deposit and the rest will be paid when I show the completed project online to him.

Now my question is, since I know CSS is viewable online and there is no way to encode it, apart from the fact that I need to trust him, is there any way that I can protect my work from being stolen before the final payment?

How do theme developers usually work remotely?

I would appreciate if you please share your experiences with me


答: At our company we use some tools who actually generate C++ or C# classes with data downloaded from the internet. These classes are data containers and contain a large number of objects in lists. </p>


问:
Best resources to really understand run-time complexity
I'm familiar with the basics of run-time analysis such as what makes certain types of code O(n) and O(n^2).  But I'm having real trouble learning, understanding, and really remembering how to analyze pieces of code that run in other complexities such as O(n log n) or O(2^n).  I'm looking for resources that explain in simple terms how these other complexities work and some practice problems to really force my understanding.</p>

答:
I think the deeper issue here is algorithm analysis. It's easy to figure out what an algorithm's runtime complexity is if you know what's actually going on in the algorithm.

A book like Introduction to Algorithms will give you all the tools you need, and more than enough practice problems, and you should see the first answer here to get a great overview of the different runtimes.

Overall, however, practice makes perfect. When you multiply two numbers, you don't "remember" how multiplication works - you just multiply them because it's second nature. After you analyze enough algorithms, you being to understand what's really happening. You don't need to "remember" how algorithm analysis works - you just look at the algorithm, see what's happening, and you understand what's happening.


答:
Well, he is willing to pay 1/3 in advance, so I would show some good will and trust and wouldn't care about that.

But if you insist on some technical solution, then you could show him your work via some shared screen (Skype and others IM programs have this feature). Also with some shared desktop (such as LogMeIn) you could let him try application and watch him.

OTOH, as a client, I wouldn't be very happy about that, but I am good man throughout :)

Title: CSS remote contract


问:
How can you demonstrate scalabity and load balancing property of a cloud application on Windows Azure?
For my project I want to develop an web application with Windows Azure as the platform using C# language. The idea is to host the website of a University on the cloud. Whenever it announces the resutls online there is a spike and the cloud will handle the peak usage with its scalabilty and load balancing properties and deploy necessary resources.

However since all of this is handled by Azure internally there is no way of demonstrating it in our project. Is there a way where we can specifically implement something to demonstrate it to the evaluator?

A virtual way perhaps...

答:
you can use performance tools that generate requests to the server and measure the response time, server resources etc.

I've used HP's performance center & VUGen in the past, and it worked well for me.


问:
How do you prevent the piracy of your software?
Is it still worth it to protect our software against piracy? Are there reasonably effective ways to prevent or at least make piracy difficult?</p>

答:
I'm considering selling my software to China, and considering how rampant software piracy is, I want to at least know who is stealing my software so I can get some metrics for Advertisers who may want to sell ads within my free app.

For that purpose I use SLP from http://www.inishtech.com/.  I track all the users of my software, and get an idea how compliant people are.  I don't expect much more than to use it as a reporting tool, but it's able to do much more.


问:
Reestimation (ideal hours + elapsed time)
At the beginning of every iteration our whiteboard is covered with "not started" stories estimated in IDEAL HOURS. On a daily basis we update these estimates to keep track of each task's progress. I think we are doing it wrong. The original estimates are in ideal hours and our daily "re-assessment" in ELAPSED TIME. This seems inconsistent, right?! How would you measure your progress towards the end of the sprint?</p>

答: We never update our original estimates.  Instead we just also log total time spent on the ticket.  This gives us better information so we can review are estimation process and drive out any issues.  We also check to make sure our estimates are as close to consistent in terms of actual effort.</p>


答:
It sounds like you are confusing the "Once and Only Once" principle with the DRY principle. The DRY principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

However the Once and Only Once principle is slightly different.

[The DRY] principle is similar to OnceAndOnlyOnce, but with a different objective. With OnceAndOnlyOnce, you are encouraged to refactor to eliminate duplicated code and functionality. With DRY, you try to identify the single, definitive source of every piece of knowledge used in your system, and then use that source to generate applicable instances of that knowledge (code, documentation, tests, etc).

The DRY principle is usually used in context of actual logic, not so much redundant using statements:

Keeping the structure of a program DRY is harder, and lower value. It's the business rules, the if statements, the math formulas, and the metadata that should appear in only one place. The WET stuff - HTML pages, redundant test data, commas and {} delimiters - are all easy to ignore, so DRYing them is less important.

Source


问:
.NET CQRS Frameworks nCQRS vs Lokad.CQRS
For the last couple of weeks I've been reading up and watching any resources I can find on CQRS. I really like the concept and am keen to start delving deeper. I have only found 2 major .NET frameworks for CQRS and I am trying to evaluate the differences between them.

I am looking to implement CQRS on a noSql db, most likely RavenDB.

Lokad seems very focused on windows Azure, not sure if it supports Raven. It has extensive documentation but not a lot of activity in the community. nCQRS has a lot of activety and supports Raven.

I was wondering if anyone has any experience working with these two frameworks and what the major differences are between them.

答:
Besides "CQRS" solutions, what's often applied is an ESB (Enterprise Service Bus). CQRS is all around messaging and these types of frameworks exist around messaging.

MassTransit http://masstransit-project.com/, https://github.com/MassTransit/MassTransit

NServiceBus http://www.nservicebus.com/, https://github.com/NServiceBus/NServiceBus

Eh, BizTalk, sorta.

MassTransit is Apache2 licensed. NServiceBus is LGPL/Commercial for the latest releases, I think you can get older under a more permissive license. BizTalk isn't a great solution and it's whatever Microsoft charges for it.

Some of the info from http://cqrsinfo.com/documents/cqrs-introduction/ might be of use in developing solutions around this as well.

http://twitter.com/#!/ackenpacken has a in process message dispatcher he uses. I'm not sure if it's out there anywhere but I've seen it :) For fun his latest example I saw had the consumers implementing ICanHaz<T>.


问:
Customizing configuration with Dependency Injection
I'm designing a small application infrastructure library, aiming to simplify development of ASP.NET MVC based applications. Main goal is to enforce convention over configuration.

Hovewer, I still want to make some parts "configurable" by developpers.

I'm leaning towards the following design:

```<code>public interface IConfiguration
{
    SomeType SomeValue;
}

// this one won't get registered in container
protected class DefaultConfiguration : IConfiguration
{
    public SomeType SomeValue { get { return SomeType.Default; } }
}

// declared inside 3rd party library, will get registered in container
protected class CustomConfiguration : IConfiguration
{
    public SomeType SomeValue  { get { return SomeType.Custom; } }
}
</code>```

And the "service" class :

```<code>public class Service
{
    private IConfiguration conf = new DefaultConfiguration();

    // optional dependency, if found, will be set to CustomConfiguration by DI container
    public IConfiguration Conf { get { return conf; } set { conf = value; } }

    public void Configure()
    {
        DoSomethingWith( Conf );
    }
}
</code>```

There, the "configuration" part is clearly a dependency of the service class, but it this an "overuse" of DI ?

答:
Normally DI frameworks do something like container.GetInstance<T>() to get an instance of the type T. This doesn't require each new type to have a code change to your configuration class. Then you can set it up like container.Configure(x => x.For<T>().Use(() => default(T))) or whatever else makes sense.

Now where the power really starts to shine is when you have...

```<code>public class Service
{
  public Service(IConfigurationObject config)
  {
    _config = config;
  }
  readonly IConfigurationObject _config;
}
</code>```

And the container automatically fills out your constructor with the dependency. I'd start out with understanding a container before digging into this too deeply yourself. http://structuremap.net/structuremap/QuickStart.htm is as good place to start as any other.

Body:
Normally DI frameworks do something like container.GetInstance<T>() to get an instance of the type T. This doesn't require each new type to have a code change to your configuration class. Then you can set it up like container.Configure(x => x.For<T>().Use(() => default(T))) or whatever else makes sense.

Now where the power really starts to shine is when you have...

public class Service
{
  public Service(IConfigurationObject config)
  {
    _config = config;
  }
  readonly IConfigurationObject _config;
}

And the container automatically fills out your constructor with the dependency. I'd start out with understanding a container before digging into this too deeply yourself. http://structuremap.net/structuremap/QuickStart.htm is as good place to start as any other.


问:
Should I redo an abandoned Dynamic Data project with Lightswitch?
I had a small project that I was doing on the side. It was basically a couple of forms linked to a DB. Access was out, because it was a specifically meant to be a web application. Being a small project I used ASP.NET Dynamic Data, but, for various reasons, the project ended before deployment. I met the client recently, and he said there was a need for it still.

I'm considering restarting the project with Dynamic Data, but I've seen some Lightswitch demos, and was suitably impressed with the BETA. I will wait for RTM if I use it, but is it a good idea to use Lightswitch to replace the Dynamic Data? The amount of work I put into the Dynamic Data site isn't really an issue.

Additional information: It's a system that tracks production in a small factory, broken down by line, machine, section and will generate reports. I would guess that the data structure will remain fairly constant over time, but that the reporting requirements will grow. The other thing is that the factory is part of a larger group, and I'm hopeful that, if this system succeeds, similar work with be forthcoming for other factories.

答:
An important note here is that LightSwitch isn't actually a web app. It can be a Silverlight app that's web deployed. So if a web based approach is a requirement, then keep that in mind.

Now would LightSwitch work better than a DynamicData application? It's hard to say, play with it a while and figure out what you feel more comfortable with. Being a web developer for a long time I'd rather use DynamicData personally.


问:
Website Planning Help
There are a lot of posts on this but I'm kinda looking for specific help, I've typed many different queries into Google but the majority of page returns seem to be dominated by beginner tutorials, planning, generators, and lots of other rubbish related information, It may have something to do with that fact that I'm rubbish at searching for content on search engines, but that's besides the point!

I'm just about to endeavour on an adventure to create a pretty stylish looking, very functional, adaptable website.

But I don't want to miss anything out.

Its happened too many times where I've come up with an idea, planned, planned, designed, implemented, then realised I've missed something, or something's wrong and I've had to turn the website on its head in order to compensate. Im sure other people have had similar situations.

My Question is:

What is everything I need to consider before actually coding my website?

I'm talking from coding standard, implementation, design aspect,abstract point of view.

Currently, I have:

designed the look of the website.

Made storyboard like diagrams for every page, action, event.

invented content.

designed a style guide.

mapped animation.

modularised my functions.

considered audience.

considerend diversity (including cross-browser compatibility, screen resolution and font size)

created a nice directory

AND FINALLY...

have included my frameworks (css reset, jQuery, images, wordpress, etc)

Is There anything else?
What am I not considering?

I just wanted to make sure I've covered every aspect before I sit down (with my brand new coffee machine) and code like a fairy on crack.

If anybody has come across any worthy articles... Please share.

But please, no "how to make a website" beginner articles. Purely in the context of the question.

Personal preferences and responses are preferred!

What planning/design steps do you take before embarking on a monster website mission?

Thank you for reading this long ASS boring question

Alex

答:
A few glaring things that I'm not seeing in your considerations:

Version Control - you may be using this, but how does it fit into your deployment schedule?

Deployment - how are you going to implement new changes? If you're thinking by FTP, you may want to reconsider. You should look at automated deployment that works best with your version control/language of choice.

Security - if someone were to come to your site to try and compromise it, how would they do it? SQL? Apache? Some functions that you've left out in the open? Do you need SSL?

Testing with your audience - please, for the love of your user, check out http://ux.stackexchange.com and do some testing with your users.

That's pretty much all I can think of right now (its early!).

Title: Website Planning Help


问:
How to implement DRY principle when using 'using' keyword?
Consider these methods:

```<code>public List<Employee> GetAllEmployees()
{
    using (Entities entities = new Entities())
    {
        return entities.Employees.ToList();
    }
}

public List<Job> GetAllJobs()
{
    using (Entities entities = new Entities())
    {
        return entities.Jobs.ToList();
    }
}

public List<Task> GetAllTasksOfTheJob(Job job)
{
    using (Entities entities = new Entities())
    {
        return entities.Tasks.Where(t => t.JobId == job.Id).ToList();
    }
}
</code>```

Using block is the same and has been repeated 3 times here (of course, more than 100 times in the real application). How is it possible to implement DRY (Don't Repeat Yourself) principal for using block? Is it considered a breach of DRY principal at all?

Update: I'm not talking about what has been implemented inside the using block. What I actually mean here, is the using (Entities entities = new Entities()). This line is repeated 100 times or more.

答:
My favorite bit of uncomprendable magic!

```<code>public class Blah
{
  IEnumerable<T> Wrap(Func<Entities, IEnumerable<T>> act)
  {
    using(var entities = new Entities()) { return act(entities); }
  }

  public List<Employee> GetAllEmployees()
  {
    return Wrap(e => e.Employees.ToList());
  }

  public List<Job> GetAllJobs()
  {
    return Wrap(e => e.Jobs.ToList());
  }

  public List<Task> GetAllTasksOfTheJob(Job job)
  {
    return Wrap(e => e.Tasks.Where(x ....).ToList());
  }
}
</code>```

Wrap exists only to abstract that out or whatever magic you need. I'm not sure I would recommend this all the time but it's possible to use. The "better" idea would be to use a DI container, like StructureMap, and just scope the Entities class to the request context, inject it into the controller, and then let it take care of the lifecycle without your controller needing to.

Body:
My favorite bit of uncomprendable magic!

public class Blah
{
  IEnumerable<T> Wrap(Func<Entities, IEnumerable<T>> act)
  {
    using(var entities = new Entities()) { return act(entities); }
  }

  public List<Employee> GetAllEmployees()
  {
    return Wrap(e => e.Employees.ToList());
  }

  public List<Job> GetAllJobs()
  {
    return Wrap(e => e.Jobs.ToList());
  }

  public List<Task> GetAllTasksOfTheJob(Job job)
  {
    return Wrap(e => e.Tasks.Where(x ....).ToList());
  }
}

Wrap exists only to abstract that out or whatever magic you need. I'm not sure I would recommend this all the time but it's possible to use. The "better" idea would be to use a DI container, like StructureMap, and just scope the Entities class to the request context, inject it into the controller, and then let it take care of the lifecycle without your controller needing to.


答:
Metaprogramming

Metaprogramming is a controversial technique in many shops. The reason is, like any powerful tool, the magnitude of help or hurt is large.

Pros

More Expressive, less code to write and maintain(often by an order of magnitude or more)

Consistency, more consistent behavior over the class of problems your solving with the code

Productivity, less code for a solution to a larger problem space

Cons

Complexity, it can be very complicated even though there is less code

Safety, sometime type safety and static analysis in general will be sacrificed

Bugs Affect More, Small errors will have a larger impact

I am a huge fan of metaprogramming, but I've been doing it for a long time.  To me the tradeoff of reduced code size and consistent behavior more than make up for the risks.  Less code means less bugs, less code to maintain, and I can usually add large pieces of functionality very quickly.

However, this does not mean I think all programmers should engage in it.  I've seen and had to fix big problems created by metaprogramming.  Usually from when people who don't understand the concept and have attempted to extend the functionality, or just fix a bug.  It takes a particular mind set that is at the very least detail oriented.  The question to use metaprogramming techniques should be a team decision.  If you have team members who don't understand, don't have the temperament for it, or are just against it none of the team should use metaprogramming.


问:
Does having Master's degree in Computer Science help your career?
I am curious about experiences of programmers who have gone beyond college or university and now work in the industry. I am not talking about academia (you need PhD there anyway). Do you have a Master's degree? Has it helped your career? Are there any other benefits besides the knowledge one gains while pursuing the degree?</p>

答: A masters degree is not neccesary in the software industry. There are plenty of jobs you can land simply having an undergraduate degree combined with the right experience. Avoiding post-grad studies can save you time and money. Having said this, if you want to work for companies such as Oracle, Google, Microsoft, IBM etc then getting a masters/PhD is recommended.</p>

OwnerDisplayName: Siamac Nikoo


问:
Is structural typing in a hierarchical model necessary?

This is part of a series of questions which focuses on a project called the Abstraction Project, which aims to abstract the concepts used in language design in the form of a framework.

Another page associated to it related to ease of use can be viewed here.  The meta-topic associated to an inquiry about the framework and the proper place to post can be found here.

I'm writing a framework which describes the concepts within static high-level languages (like C#, VB.NET, et cetera). As a part of that, it involves synthesis of the structures that describe those concepts.

One question I had was about what's called Structural Typing, which I aim to implement through type-parameters (constructors with parameters would be a definite addition.)   It's a concept that neither C# nor VB.NET implement.

The question I have today is: is structural typing in a hierarchical model necessary?

One small example that I can think of is models developed that rely on patterns, but don't necessarily have an interface to specify this pattern.  This is useful in instances where you want to use the code for multiple base types without a common ancestor, but with similar structure.

If you wanted to display a list of items to the Console via their name, you'd need to write one method for the lowest common ancestor that defines that name property.  Person, Control, and Type would all use different methods, as an example.

If implemented, the resulted code would look something like:

```<code>public static void DisplayNames<T>(IEnumerable<T> namedItems)
    where T has
    {
        ///<summary>Returns the item's name</summary>
        string Name { get; }
    }
{
    foreach (var namedItem in namedItems)
        Console.WriteLine(namedItem.Name);
}
</code>```

The '[' and ']' are used for disambiguation reasons (it'd be difficult to try to discern the body of a type-parameter's structure from an interface's structure otherwise.)

Suggestions welcome.

答:
Given that most of the above answers essentially provided more context as to the nature of what structural typing is, not so much focused on whether it was necessary, as the initial question stated.  I will mark this answer as implicit and based upon the target audience of the language.

For certain programming patterns a structural typing model on top of a static typing model is warranted; however, at the same time the specific implementation or current implementations don't add relevant context to the question at hand as they are examples of it in use.  They explicitly state it is possible, but don't relate how it being possible relates to the need aspect initially requested in the original question.

Thus we'll answer the question by the following: it's needed where appropriate in a development environment that provides explicit type-based implementation constraints as well as an environment where two separately developed libraries follow the same pattern but do not share a common ancestor or implement the same interfaces, this is where structural typing would come into play.

Use cases are easier to come up with given a language that promotes both kinds of typing as noted by @back2dos, but that in and of itself does not answer the need aspect, it answers the question of whether it can be done.


问:
ASP vs javascript vs jQuery vs User Controls vs AJAX
Increasingly when developing sites I find myself utilising more client side technologies such as Javascript, jQuery and AJAX.

For three different pages I measured the size of the HTML sent to the browser (excluding images and CSS).

What I found was:

A page that has normal ASP.NET controls + a little bit of jQuery: approx. size = 30kb

A page using some user controls that have AJAX and client side support: approx size = 50kb

A page that uses more complex user controls from a library with heavy client side support: approx. size = 110kb

As you can see the size of data transferred seems to increase as client side support and AJAX features are added.

This adds to the bandwidth requirements of the site and presumably the servers I/O load which may reduce the number of concurrent users that can be served.

Should I worry about balancing rich client side features and interactivity with server's load and bandwidth use?

What are the priorities, if any?

答: Make sure you enable gzip on the server and that the client uses it. This will reduce bandwidth.</p>

OwnerDisplayName: AtoMerZ


答:
This may not be applicable to this particular instance of your website (since you mentioned wordpress in the post), but here are some things I noticed missing:

What about your data model?

What about entity relationships?

I.e. how does content on your site relate to other content?  Do all blog posts have tags? Do blog posts have categories?  What's the difference between tags and categories?

Here's an example of a conceptual data model.

Also, have you thought about a favicon? :)

Title: Website Planning Help


问:
Is the C programming language still used?
I am a C# programmer, and most of my development is for websites along with a few Windows applications. As far as C goes, I haven't used it in a long time, as there was no need to. It came to me as a surprise when one of my friends said that she needs to learn C for testing jobs, while I was helping her learn C#.

I figured that someone would only learn C for testing if there is development being done in C. From my knowledge, all development related to COM and hardware design is also done in C++. Therefore, learning C doesn't make sense if you need to use C++. I also don't believe in historic significance, so why waste time and money in learning C?

Is C still used in any kind of new software development or anything else?

答:
All of the modern languages I have seen may interact with C:

C++

Java

C#

Python

Haskell

Objective C

Rust

The need to interact with C derives from:

C having a simple ABI

C being around for a long time

It means that since those languages can communicate with C, they can:

leverage its libraries

communicate with each other through C (for example, Clang is written in C++ but offers Python Bindings hooked on its C interface).

And I would bet that all of them rely on C for their runtimes (unless they went full assembly ? dubious).

C is the Lingua Franca of the programming languages and one of the simplest (ABI-wise) not tied to a specific architecture (like assembly is), it'll take a major shift to get rid of it.


问:
When to Use workflow engines?
I've worked in past on some of the workflow engines as programmer but never had a clarity on why we chose the work-flow engines in first place. And as programmer I know that there are at least 100 ways to do anything when you are writing code but only few of the ways are the best!

I still don't understand which use cases are best solved by workflow engines (or rather their concept) than designing a good DI enabled application. I'm looking for any general characteristics of domain-neutral use cases, where work-flow engines are one of the the best options.

So my question is: What are general characteristics of a requirement which can be taken as a signal for opting for a good workflow engine and coding around it?

答:
I know you asked for use cases, but it's easier to list the advantages than to imagine all possible use cases.  The advantages of course depend on the engine and language you are comparing, but in general:

Keeping rules as data instead of code means you don't have to recompile, so you can test changes quickly, change at run time, etc.  Not much of an advantage if you don't have to recompile in the first place, though.

Users can more reasonably be expected to edit the rules.  They can potentially tinker with them interactively in ways that aren't feasible when having a programmer write code for them.

Keeping rules as data allows tools to be written to visualize and change the data.

Keeping rules as data allows meta-programming more easily - you can write code to analyze the data and insert more in some complex way, which would be very difficult for code.

All of these things are possible to do directly with code (e.g. - write a C# parser to find all rules of a certain type and generate code for more rules, insert it dynamically into an assembly in a manner that permits assembly unloading, write tools for users to be able do this as well using your visualizer and editor) but may be much more difficult depending on your language (programmers using a Lisp might refer to items 1-4 as "programming").

Title: When to Use workflow engines?


答:
Not only using is duplicate code (by the way it is duplicate code and actually compares to a try..catch..finally statement) but the toList also. I would refactor your code like this:</p>

```<code> public List<T> GetAll(Func<Entities, IEnumerable<T>> getter) {
    using (Entities entities = new Entities())
    {
        return getter().ToList();
    }
 }

public List<Employee> GetAllEmployees()
{
    return GetAll(e => e.Employees);
}

public List<Job> GetAllJobs()
{
    return GetAll(e => e.Jobs);
}

public List<Task> GetAllTasksOfTheJob(Job job)
{
    return GetAll(e => e.Tasks.Where(t => t.JobId == job.Id));
}
</code>```

Body:
Not only using is duplicate code (by the way it is duplicate code and actually compares to a try..catch..finally statement) but the toList also. I would refactor your code like this:

 public List<T> GetAll(Func<Entities, IEnumerable<T>> getter) {
    using (Entities entities = new Entities())
    {
        return getter().ToList();
    }
 }

public List<Employee> GetAllEmployees()
{
    return GetAll(e => e.Employees);
}

public List<Job> GetAllJobs()
{
    return GetAll(e => e.Jobs);
}

public List<Task> GetAllTasksOfTheJob(Job job)
{
    return GetAll(e => e.Tasks.Where(t => t.JobId == job.Id));
}


答:
A workflow engine is useful when you need to go from a start to a finish but there are many different paths/logic/rules to get there.

For example, let's say I write a program that publishes content.  So, in my case, the publishing goes through a review process, legal, and then final approval. I write up the program implementing my process logic and steps.  Now this work great for me and my company.  So, I decide others should use my program.

Unfortunately, not everyone publishes content using the same process, so instead of writing separate processes for each different case, we would implement a work flow process so the program is flexible to accomodate everyone.  No matter how many steps or rules or logic are between those two points the result is the same.

So, if you have processes that are variable from start to end, use a workflow.  If the same process can be used by everyone, then you don't need a workflow.

Title: When to Use workflow engines?

Body:
I've worked in past on some of the workflow engines as programmer but never had a clarity on why we chose the work-flow engines in first place. And as programmer I know that there are at least 100 ways to do anything when you are writing code but only few of the ways are the best!

I still don't understand which use cases are best solved by workflow engines (or rather their concept) than designing a good DI enabled application. I'm looking for any general characteristics of domain-neutral use cases, where work-flow engines are one of the the best options.

So my question is: What are general characteristics of a requirement which can be taken as a signal for opting for a good workflow engine and coding around it?