答:
I am a poor mathematician - numerical methods (Computer Science 412) was a class I took several times, and please don't ask me to do an integral calculus problem.  When I was done with it, I thought I'd never touch such a math problem again.

A number of years later, I wanted to make an image of an animated braid in RGB as an avatar.

I did that. While the math to get the three sine waves was easy (highschool math), the question of when does one stand overlap another took some thought and turned out to require a small bit of numerical methods (that CS 412 class I took - the derivative of a function, quite easy... but I still had to recognize it and solve it).

Its a trivial example, but one you may come across.  It wasn't the math that was the hard part, it was the recognizing the class of the problem.

A recent example from Programmers.SE: What class of problem is this, and what math do I need to know to solve it?

How does one calculate this? It reminds me of solving matrices in high school. Is this something that can be done with matrices? What is this problem called? What do I need to know to solve it?

This as pointed out in the answer is linear programming.  Again, it isn't about solving the problem, it is about recognizing the class of the problem and being able to find out how to solve the problem.

At my previous place of employment, there was a person working on a computer program to optimally cut carpets.  Optimal Carpet Cutting shows how this can be done.  It involves some math (frankly that is a bit above what I can understand with a glance).  And yes, this was being done for a webapp (there is even more fun in that of trying to figure out how to send it from the back end to the client - do you json it up and rerender it? how would you store that? Or maybe just generate an image on the back end?).

.

I was working on a point of sales system and working on getting the correct numerical formats in a number of places and tracking down missing pennies in receipts that were thousands of dollars (coupons and promotions and packages oh my!).  Tracking through this code required some advanced algebra and the recognition of the implications of doing certain operations in different orders.  Identifying and simplifying things such as Math.pow(10,foo) / Math.pow(10,bar) to Math.pow(10,(foo - bar)) made some of the code run a little bit cleaner.

Another problem that was being tackled was reducing the complexity of the spline of a person's signature without changing the shape.  (The following image is not what I was working on, but serves to illustrate the problem)

Which of those points are the least significant ones that can be removed (to fit in some other antiquated system that has a limit to the number of points in a signature)?

Continuing on this, and especially applicable to a front end web person you may often find yourself working with splines in web animations.  Look at w3 on SVG animations and the inkscape wiki.  You may find yourself wanting to do a chord diagram (glance at circos for some 'wow' visualizations of this nature)

And one last bit, being a backend tools person, I often found myself doing reports against my tools.  This often touched into stats (standard deviations, mean, median, mode, outliners, statistical significance, best fit lines, identifying the proper graph to present the data, etc..)

The point I am trying to make is that there are many places - both on the front end and the back end - that make use of some higher math.  You may find yourself in careers that don't make use of this at all.  It is quite possible.  However, you will more than likely find yourself needing some advanced math at some time.

As a programmer, any math you can get your hands on and head around will likely be useful in the future. I can't say if you will find simple numerical methods the limit of where your career will take you, or if you will find yourself trying to determine the optimal cutting of carpet, or trying to explain to a client why it is not a good idea to represent all the possible ways to arrange 7 items on a single web page.

Title: Web Developer and Math


问:
Best way to test a reimplemented web service
In my team, we are about to start the reimplement of a service. One of the important steps to do to accomplish this is how do we ensure that we are doing it in the right way and  we are not introducing new bugs.

So, what we have in mind is create a bunch of test to verify the following:

The behavior. Both services should behave the same way (store data in the same places, send same, notificacions, etc...)

Results. Object returned by the service's calls should be exactly the same.

So, the things that we have thought is to do the following:

Create a set of test that verifies the behavior and results of old service.

Create the new service adding unit test, and whitebox integration test for the new service

Create some kind of "Mirror test" that checks if the new service is working as the old one. Is there a way to do this?

Thanks for any help.

Note: None of the code of the previous version is reusable. There is no test for the older version of the service

[Edited]replaced original word "migrate" with "reimplement"

答:
Well, after diving deep in this, we have two possible solutions:

Replay prod data: It will be kinda complicated to do it, but the good thing is that if you can capture and replay prod data against your service, then all whitebox integration test will be done for you. the bad thing is that you are just testing the inputs and outputs and not how the data is changed by the service.

A different approach is the following: Apply factory pattern for both service's clients, the old one and the new one, then create a test for the old service (here you want to check result objects and data changes), migrate the service, test your new service against the test of the old one.

ContentLicense: CC BY-SA 3.0


问:
Web Developer and Math
I have just learned HTML/CSS and I practice everything I read to make it more understandable to me and I really enjoy it. My goal is to be a Modern Web Developer both front and back-end, so I won't stop learning. I'm planing to jump on JavaScript now but what I would like to know is how important is math to being a Web Developer.

Do I need to know math?

If so, what kind of math should I know and understand?

答:
If you're using CSS to do any kind of non-trivial layouts, especially if you're going the whole Responsive design/fluid grid/best practices/whiz-bang-pow route, you're going to be crunching a lot of numbers.

For example, say you have a 960px wide page, and you need to put 5 boxes on it, flush against the sides, with gutters in between:

Lets assume we'd like to try for 20px wide gutters, and hope the math works out. That's leaves us with a bit of algebra:

```<code>5x + 4(20) = 960
</code>```

So solving for X tells us that are boxes are each 176px wide. However, we're working with a responsive fluid grid so pixels won't cut it. We need that as a percentage so we pull out our responsive equation (from the book):

```<code>(target/context)*100 = percentage
</code>```

But wait! It turns out we'll need multiple rows, and so can't just use :first-child or :last-child to cancel out the extra margin. We could use nth-child(5n) (look! Math!), but we want legacy browser support, so we'll wrap the boxes in a container that's 20px wider than the 960px and give it a negative right margin.

So the container width is: (980px/960px)*100 = 102.083%

And the container's right margin is: (-20px/960px)*100 = 9.375%

And the boxes' widths are: (176px/980px)*100 = 17.959%

And the boxes' right margins are: (20px/980px)*100 = 2.041%

And then lets assume we want each box to be the same height as 6 lines of text, and that we're using the default font size of 16px, with our line height set to 1.5 (16px*1.5 = 24px), and we're using ems for our vertical units, which are factors of the current font size.

That means the height of one box is (6*24px)/16px = 9em.

And if we want a 20px margin between the rows, the boxes need a bottom margin of 20px/16px = 1.25em

So yes, I find math very important when writing CSS, and often javascript. At the very least, knowing when you'll need a certain piece of algebra, geometry, or even trigonometry will come in very, very handy.

Even with modern pre-processors, the computer can only crunch the numbers, you need to figure out which numbers to crunch.

Title: Web Developer and Math

Body:
If you're using CSS to do any kind of non-trivial layouts, especially if you're going the whole Responsive design/fluid grid/best practices/whiz-bang-pow route, you're going to be crunching a lot of numbers.

For example, say you have a 960px wide page, and you need to put 5 boxes on it, flush against the sides, with gutters in between:

Lets assume we'd like to try for 20px wide gutters, and hope the math works out. That's leaves us with a bit of algebra:

5x + 4(20) = 960

So solving for X tells us that are boxes are each 176px wide. However, we're working with a responsive fluid grid so pixels won't cut it. We need that as a percentage so we pull out our responsive equation (from the book):

(target/context)*100 = percentage

But wait! It turns out we'll need multiple rows, and so can't just use :first-child or :last-child to cancel out the extra margin. We could use nth-child(5n) (look! Math!), but we want legacy browser support, so we'll wrap the boxes in a container that's 20px wider than the 960px and give it a negative right margin.

So the container width is: (980px/960px)*100 = 102.083%

And the container's right margin is: (-20px/960px)*100 = 9.375%

And the boxes' widths are: (176px/980px)*100 = 17.959%

And the boxes' right margins are: (20px/980px)*100 = 2.041%

And then lets assume we want each box to be the same height as 6 lines of text, and that we're using the default font size of 16px, with our line height set to 1.5 (16px*1.5 = 24px), and we're using ems for our vertical units, which are factors of the current font size.

That means the height of one box is (6*24px)/16px = 9em.

And if we want a 20px margin between the rows, the boxes need a bottom margin of 20px/16px = 1.25em

So yes, I find math very important when writing CSS, and often javascript. At the very least, knowing when you'll need a certain piece of algebra, geometry, or even trigonometry will come in very, very handy.

Even with modern pre-processors, the computer can only crunch the numbers, you need to figure out which numbers to crunch.


问:
Are there any programming languages that make use of adjectives?
Are there any languages where something like the following might be possible?

```<code>people = [ ... a list of people ...]
Person jake = Person("Jake", 165, ...)
jake is Tall
people.add(jake)
for Person person in people where Tall:
    // ... do something terrible to them
jake is not Tall // ... Jake no longer wishes to be tall
</code>```

I hope that makes sense - basically, dynamic adjectives that affect something about an object's properties or methods.

答:
Firstly, that looks like Python.

Secondly, things like Tall aren't necessarily reflexive. Lets assume as a part of our syntax:

is can be an infix operator that and sets an object attribute, eg. Jake is Tall makes Jake.Tall True

is can be a prefix operator that queris the precence of an attribute.

Being over 185cm is tall

So lets begin:

```<code>Jake <= Person(name="Jake")
Jake is Tall
print(is Jake Tall)
>>> True
</code>```

All is well, but this introduces problems.

```<code>print(Jake.height)
</code>```

We know Jake is tall, but how tall is he?

Even again:

```<code>Jake <= Person(name="Jake",height=199)
Jake is Tall
print(is Jake Tall)
</code>```

What do we print here?
Now, we've said Jake is less than 200cm, so he isn't Tall, but he've also explicitly stated that he is tall. We can start to introduce logic so that when we call Tall against a person we check the Tall state or the height attribute, but the logic incongruencies are difficult.

What you can do is similar to what Python does with its is statement, and use it to check a state, rather than set it.

So we could go:

```<code>Jake <= Person(name="Jake",height=199)
if Jake is Tall {
    print("How is the weather up there?")
} else {
    print("Need a ladder?")
}
>>> Need a ladder?
</code>```

This syntax could then just be a shorthand of Jake.isTall or any number of attribute checkers.

Body:
Firstly, that looks like Python.

Secondly, things like Tall aren't necessarily reflexive. Lets assume as a part of our syntax:

is can be an infix operator that and sets an object attribute, eg. Jake is Tall makes Jake.Tall True

is can be a prefix operator that queris the precence of an attribute.

Being over 185cm is tall

So lets begin:

Jake <= Person(name="Jake")
Jake is Tall
print(is Jake Tall)
>>> True

All is well, but this introduces problems.

print(Jake.height)

We know Jake is tall, but how tall is he?

Even again:

Jake <= Person(name="Jake",height=199)
Jake is Tall
print(is Jake Tall)

What do we print here?
Now, we've said Jake is less than 200cm, so he isn't Tall, but he've also explicitly stated that he is tall. We can start to introduce logic so that when we call Tall against a person we check the Tall state or the height attribute, but the logic incongruencies are difficult.

What you can do is similar to what Python does with its is statement, and use it to check a state, rather than set it.

So we could go:

Jake <= Person(name="Jake",height=199)
if Jake is Tall {
    print("How is the weather up there?")
} else {
    print("Need a ladder?")
}
>>> Need a ladder?

This syntax could then just be a shorthand of Jake.isTall or any number of attribute checkers.


答:
Inform 7 is a natural-language programming language, heavily geared towards writing interactive fiction.

It has a rich variety of ways to express and use adjectives:

Simple two-state attributes: "John is sunburnt."

Inform will automatically understand the opposite of this to be "not sunburnt". You can specify both labels though: "A person can be tall or short. John is tall."

Enumerations (what Inform calls "kinds of value"): "Colour is a kind of value. The colours are red, green and blue. The box has a colour. The box is blue."

Rule-based definitions for computing whether an adjective applies: "Definition: a thing is heavy if its weight is greater than 10kg." Alternatively: "Definition: a thing is heavy rather than light if its weight is greater than 10kg."

Having defined these adjectives, there are many ways to use them, and they're understood both by the compiler and by the runtime parser accepting user input. Some simple examples:

Assign them to objects: "Now the box is red."

Test for their presence: "If the person is short..."

Discriminate between objects to which the same adjective could apply: "If the heaviest box is red..."

With apologies to the writers of Inform documentation for any examples I might unwittingly have borrowed. I imagine things like weight and colour crop up often :P

Title: Are there any programming languages that make use of adjectives?

Body:
Are there any languages where something like the following might be possible?

```<code>people = [ ... a list of people ...]
Person jake = Person("Jake", 165, ...)
jake is Tall
people.add(jake)
for Person person in people where Tall:
    // ... do something terrible to them
jake is not Tall // ... Jake no longer wishes to be tall
</code>```

I hope that makes sense - basically, dynamic adjectives that affect something about an object's properties or methods.


问:
Keeping third-party source code up to date
What is the best way to keep third-party source code up to date?

For instance in my app, I'm using third-party source code from an open GitHub repository. What I've done is that I have downloaded the zip of the source code, unpacked it and imported it in my iOS app and then started modifying this source code to my hearts content.

So this third-party source code has been working great for me, but now some months later the developer of the third-party source code released an update to his code from 1.0 -> 2.0. Now of course I want to have this update as well in my iOS app. What would be the easiest way to migrate my 1.0 third-party source code (together with all my additions to the code) to 2.0?

答:
In getting a copy of the code and making local changes to it, you have effectively branched it.  Meanwhile, back on the main line other changes have taken place and a 2.0 version has been released.

Note that these #1, #2, #3 do not need to match up, nor are they the same feature - just a representation of several changes that have been made to each codeline.

This is what it looks like now, and you are trying to make that merged 2.0 point.

Just doing a diff of the code at Your change #3 and version 2.0 will show you what has changed between the two, but it doesn't show how that fits in.  Unless you have marked your code somehow, you will have difficulty determining if the difference between your change #3 and version 2.0 is changes that new features in the mainline, or changes you did in your branch.

For this, you need to use diff3 that that implements a three way merge of the your code, the oldest code, and their code.  This takes the version 1.0 as a change.

The man pages for diff3 on developer.apple.com and opendiff on developer.apple.com (you can also use FileMerge on the mac - remember to expand the window for the 3 way diff.  See also How do you do a 3-way merge in FileMerge? - you may also find p4merge from perforce to be to your liking).

Merging an entire major upgrade may be a significant undertaking. I can't say how much has changed in the mainline between version 1.0 and version 2.0.  Long term, you should consider using git, forking the repo and then consistently doing pulls of changes into your branch.  This is covered under pull in upstream changes in the git fork a repo article.  Doing this for smaller changes will help you keep your code up to date and also reduce the workload compared to major changes.  It will also keep you up to date if there are major sections being reworked that you have changes in so that you are aware you will need to budget time there to reintroduce your changes.


答:
I think that we have tried our best to most cleverly sway from the problem at hand. To kindly circle back to the facts. As anyone programmer will tell you we are self taught. I think it would be a great disservice to yourself to not start coding because you feel like you could sleep through a trigonometry class as I know I would. I would never say math would not hinder me as a programmer. But math never stopped me from trying to learn anything to do with programming. It is a fact that it is not worth waiting to learn javascript because of mathematics.
You will have many phases of learning to conquerer before you will be coding a clever man walking towards your last click.</p>

Title: Web Developer and Math

Body:
I have just learned HTML/CSS and I practice everything I read to make it more understandable to me and I really enjoy it. My goal is to be a Modern Web Developer both front and back-end, so I won't stop learning. I'm planing to jump on JavaScript now but what I would like to know is how important is math to being a Web Developer.

Do I need to know math?

If so, what kind of math should I know and understand?


问:
Career advice: stay with PHP or start a new career in something else ( .Net?)
I'm planning on moving to NY in 6-12 months tops, so I'm forced to find a new job. When I'm planing to start my life in another city it's also probably a good time to think about career changes.

I've found a lot of different opinions about PHP vs .Net vs Java and this is not the topic here. I don't want to start a new fight about which language is better. Knowing a programming language is not the most important thing for being a software developer. To be a really good developer you need to know OOP, design patterns, testing... and a language is just a tool to make things happen.

So back to my question. I have mixed experience in IT - 1 year as an IT support guy (Windows administration and support), around 2 years of experience in embedded programming (VB.Net 2005) and for the last 2 years I'm working with PHP/MySQL. I have worked with Magento web shop, assisted in some projects in Symfony, modified few Drupal sites.

My main concerns are the following:

Do I continue to improve my skills in PHP e.g. to start learning some major PHP framework like Zend, Symfony maybe get some PHP certification.

Or do I start learning .NET or Java. I'm more familiar to .NET so I'll probably choose it if choice falls between .NET and Java ( or you could convince me to choose Java :).

Career-wise, I don't know what is the best choice. Learning a new framework and language is more time consuming then improving my existing skills in PHP. But with .NET you have a lot of possibilities (Windows 7 Phone development, Silverlight, WPF) and possibly bigger chances to find better jobs.

PHP jobs are less well payed then .NET, at least, according to my research (correct me if I'm wrong). But if I start now with .NET I'm just a beginner and my salary will be low. I need at least 2+ years of experience in some language to even try to find some job that is paying higher than $50-60k in NY. My main goal in the next 2-3 years is to try to find a job in the $60-80k category. Don't get me wrong, I'm not just chasing money, but money is an important factor when you're trying to start a family.

I'm 27 years old and I feel that there isn't a lot of room for wrong decisions regarding my career, so any advice will be very welcome.

Update

Thank you all for spending time to help me with my problem. All of the answers and comments have been very helpful. I have decided to stick with PHP but also to learn C# and Silverlight 4. We'll see where the life will take me.

答:
I think that often people mix programming languages and frameworks/technology stacks. It's relatively easy to learn a new language, but's much more difficult with big technologies. I agree with some answers that what is most important is your overall programming/problem solving experience, but I don't believe that anyone can UNDERSTAND a completely new technology in 1 week.

Sure, a large portion of developers have never read a single technical book and don't understood the very building blocks of technologies, they are using. They just hack their way out of the problems and are very "successful". I have myself started career in PHP without even understanding how HTTP works at first. But some employers, which I respect most, are expecting a deep understanding of "how things work", simply because this tends to increase chances of success of their projects.

The very least you need to do to gain this understanding is to read couple of GOOD books with enough time to prototype solutions to common problems in a new unfamiliar development environment. Is it possible to do in a week? I would love to work with people who are capable of this, but I don't hope to see such people any time soon.

Some employers actually are ready to give you enough time to gain this understanding, respecting your overall deep technical experience in other technology stacks (if you have one), but unfortunately most are not.

Also, when you are changing technologies, what is most important is your personality - how humble and curious person you are to spend enough time to understand how things work and how things are done in your new area.

So to sum up, my answer would be the following. Pick a technology, which has enough potential and which (most importantly) will make you happy in your job. Specialize in this technology, the job market will value this and few years needed to get your target salary will be worth it. But never be overzealous, spend some time with other technologies, it will make you a much better PROFESSIONAL overall.

ContentLicense: CC BY-SA 2.5


答:
I am a web developer with over six years of professional experience; primarily on the server-side but with a decent amount of client-side work as well.

When I went to high school, the school had implemented a controversial math program called College Preparatory Math. I was in the program for the first three years, then, the last year, I took a standard pre-calc class - and got a D.

Having always had an interest in computers and programming, I wanted to go to college and get a Computer Science degree. So the first year there, realizing the standard-level math classes might be too tough for me, I again took a pre-calculus class that wouldn't count towards the major. Not that that would have mattered; I got a D again. Dejected, and worried I wouldn't be able to graduate in time, I made one of the worst choices of my life and switched to an English Lit degree.

So, long story short, I have neither a CS degree nor much experience in college-level mathematics. But I'm doing okay as a web developer.

For this kind of work, more than high-level math, I think it's helpful to have a grasp of three particular things; logic, databases, and text processing. An understanding of logic is universal in development, of course, and databases are also seen in other development fields, but keen knowledge of text processing is a bit distinct; the same way that, say, a game developer will probably rarely have a need for regular expressions but need to implement trig and calc functions almost daily, a good web developer should know how to write a regex pattern in their sleep, but can probably go a lifetime without implementing the Pythagorean theorem.

That being said, it will certainly do you no harm if you can bear with it and learn higher-level math if you have the chance. As I said, I regret not sticking with it in college. Who knows; maybe you'll decide that you enjoy that stuff, and more than web development, you have a knack for graphics processing or game development.

Title: Web Developer and Math


问:
OOP way to design a manager of groups of users
Alright. I have this pattern to model that comes in two variations that are very much the same. I have a class which can be considered an "entry point" which will call a few manager classes depending on the user interaction. We can probably liken it to a controller class.

This class should allow the user to manage either groups of users or users themselves. In both cases the operations are quite similar, you can add, modify, remove, view groups and users. Groups have one more operation which is to add users inside them. That's where I am stuck on:

My original idea was to model it this way:

class User,

class Group,

class GroupManager,

class UserManager,

class IManager

However this has the problem of not being able to model the fact that groups need to be able to add users to them. If I put it inside IManager then it is available to UserManager which makes no sense and I put it as a specific method of GroupManager then I am cannot have a single "interface" which is less clean. That led me to skipping entirely the IManager class altogether and only have both managers but then it seems clunky and repetitive.

Is there a proper design pattern to apply here ?

TLDR: What is the proper design pattern where all methods to manage a group or user should have the feel of a "common interface" but still be able to model the fact that groups should be able to add users to themselves.

答:
This seems to be a problematic design for a few reasons:

FooManager is often a bad idea. See this question about how it may be a sign of bad design. After all, a UserManager is a class that does something with User objects.. but what exactly means managing here?

Single reponsibility principle - The S in SOLID is something you violate with anything that manages a group or user. By the very nature of doing this or that your component/manager no longer has a single responsibility, but at least two of them.

You already said that "Groups have one or more operation[sic.] which is to add users inside them", so you have a very natural understanding that these operations/methods belong to the Group class. You should first provide an argument of why this simple straightforward approach is not feasible in your case, before you start complicating your design.

What is the reason behind your idea that methods, which do two different things, should have a "common interface" anyways? Apart from their nature being very intuitive and everyone understanding that you can add a user to a group, everything else you design on top of that is something others will not as readily understand. So why even bother?

Finally, if you really really need to define that common interface you may take a look at the Facade pattern. It's intended for larger bodies of code (like whole packages) and again looks like overkill for a User and a Group class.


答:
Putting a method like AddUserinto the IManager class is not really a problem as long as the implementation of that method in UserManager just throws an exception (or does some other kind of error signaling.

But if groups and users are very similar from the "managers" point of view, why not introduce a common base class for Group and User (lets say IGroup, since a user can be seen as a group of just one person), and replace the two different manager classes by a single one which operates on IGroup objects in a more or less generic manner? Of course, IGroup will need an AddUser method, too, and the implementation in User should throw an exception (like in my suggestion above).

I also agree with @Frank that the name XXXManager may be chosen better, but I guess in reality you have a more expressive name and you chose that here just because of keeping your question general.

Also related (but maybe oversized for your case, when you don't have "groups of groups":) the composite pattern.

Title: OOP way to design a manager of groups of users

Body:
Alright. I have this pattern to model that comes in two variations that are very much the same. I have a class which can be considered an "entry point" which will call a few manager classes depending on the user interaction. We can probably liken it to a controller class.

This class should allow the user to manage either groups of users or users themselves. In both cases the operations are quite similar, you can add, modify, remove, view groups and users. Groups have one more operation which is to add users inside them. That's where I am stuck on:

My original idea was to model it this way:

class User,

class Group,

class GroupManager,

class UserManager,

class IManager

However this has the problem of not being able to model the fact that groups need to be able to add users to them. If I put it inside IManager then it is available to UserManager which makes no sense and I put it as a specific method of GroupManager then I am cannot have a single "interface" which is less clean. That led me to skipping entirely the IManager class altogether and only have both managers but then it seems clunky and repetitive.

Is there a proper design pattern to apply here ?

TLDR: What is the proper design pattern where all methods to manage a group or user should have the feel of a "common interface" but still be able to model the fact that groups should be able to add users to themselves.


问:
Does software reuse preclude process repeatability

Code Reuse as a Problem

I was thinking about this question on software delivery, and I kept coming back to the issue of repeatability and / or reproducibility.  They matter, because if you don’t repeat a project then it becomes more difficult to improve the process you used to build the project.  Engineering involves constantly improving the processes involved with design and construction in order to produce higher quality projects.

Software can rely heavily upon reuse due to its digital form.  Instead of rewriting a module, we just call it again or copy it to the other system.  Some examples are authentication / login or perhaps a logging function.  There are many well known examples for those categories, and conventional wisdom is to reuse what exists instead of rolling your own.

Some Comparisons to Other Disciplines

Construction

In contrast, construction of physical systems (buildings, bridges) is nowhere near as reusable.  It’s true that the blueprint of a house can be reused many times to build the same copy of the house, but the construction must be performed each time.  Cut & paste doesn’t work like that in the analog world.  Bridge blueprints are less reusable that houses because site conditions will vary.

Master builders are experts recognized for having designed and / or built tens, hundreds, or thousands of things in their area.  For example, Frank Lloyd Wright, a world renowned architect and designer designed more than 1,000 structures and completed 532 works.  Contrast that with Anders Hejlsberg who has designed “just” five languages (Turbo Pascal; Delphi; J++; C#; Typescript).  In many ways, it’s an unfair comparison because the domains are different.  But at a broad level, the quantifiable production from two very intelligent people is vastly different.

Martial Arts

Martial artists will say that mastery of a move comes only from thousands of repetitions. After a good portion of those repetitions have been put in, many martial artists are surprised at how a previously perceived to be complex kata or form has become simple. Instructors of those students will also notice how the motion becomes more fluid and purposeful as well as having an economy of motion. Likewise, experienced martial artists are able to pick up more complex katas more quickly than less experienced students. Experience from repetition has given them a framework or process that allows them to learn more quickly.

Woodworking

Woodworkers experience a similar transformation. Hobbyist woodworkers always refer back to their first project that required a lot of drawers. If they complete the project, they gain a new appreciation for the efficiencies that assembly lines produce. There are other benefits such as a better understanding of how to lay out the drawers parts on the sheet stock in order to maximize use of the wood. Compared to hobbyists, professional woodworkers are able to more quickly design, start, and construct items that they have made many times before. They also gain an ability to see inherent issues within someone else's design having made that mistake in their work.

So, does software reuse prevent software developers from becoming more proficient?

In many ways, software design and construction is always new.  We don’t repeat past works, because if we can reuse a module, library, or system then we do.  We’ll preferentially extend an existing system before rewriting the entire thing from scratch.  But repetition is what allows us to find efficiency in the design and the construction. Anyone who has practiced a sport or physical activity will tell you that repetition is the key to becoming a good practitioner.

My question: Does software’s ability to be reused prevent the necessary process improvement and efficiency that comes from repeating a project?

答:
It's all about resources. Years ago, if you developed software projects for large mainframe computers they might be around for 15 years or so with largely a static development environment. The FORTRAN program written to calculate payroll or the COBOL program was perfected over decades because it was constantly being used. There were resources to see how this could be improved. We don't have that sort of slow environment any longer to fine tune and polish the skills for a specific project. But we do take the skills and adapt them to the next project resources permitting. But in the end if becomes a choice of money spent on the new project to do the job, or to do the new job with a large amount of gold-plating. Gold-plating a project means to improve it to the nth degree and add a ton of bells and whistles even if the user didn't specifically ask for it.

The best we can do, is look at the overall design of a new project and see how it can be improved based on the past experience of the team. But it takes a real experience software architect to have a vision about what is actually considered improving the design to improve skills vs simply casing the latest buzzword in development such as Agile, OOP, etc.


问:
Design tips for a program with GUI's for basic, intermediate, advanced & expert users
I've been asked to develop a program with four interchangeable GUI's so that users can switch from basic to intermediate to advanced to expert mode seamlessly and at will.

I have a good understanding on how to separate the GUI from the business logic. That's taken care of.

My question is exclusively about how to organize, design, implement the GUI part for this particular requirement.

If any of you can help with information from languages/frameworks other than C#/NET, it will be appreciated just the same.

答:
The challenge you face is defining those four interaction modes precisely and implementing them in ONE GUI (duplication of effort is an evil beast). I'd venture to offer the following classification:

Basic workflows: wizard dialogs with as few steps/pages and parameters as possible, enough to complete the task. Parameters set to sensible defaults.

Intermediate: all parameters configurable with a point-and-click, drag-and-drop interface.

Advanced: keyboard shortcuts - defined by default for frequently used actions, configurable for all others.

Expert: integrated editor and scripting environment, exposing API for batch interaction.


答:
Applescript seems to be a good candidate.

Here are some examples, excerpt from AppleScript: Beginner's Tutorial:

```<code>tell application "Finder" to open the startup disk

tell application "Finder" to set the current view of the second Finder window to flow view

tell application "QuickTime Player" to set the current time of the front document to 94900
</code>```

Body:
Applescript seems to be a good candidate.

Here are some examples, excerpt from AppleScript: Beginner's Tutorial:

tell application "Finder" to open the startup disk

tell application "Finder" to set the current view of the second Finder window to flow view

tell application "QuickTime Player" to set the current time of the front document to 94900


问:
Why do large websites use different languages for the backend and frontend?
My understanding from small MVC applications is that you have the front end, which deals with HTML, JS, jQuery, etc, and you have the back end, which consists of your controllers and models.

However, when I talk to developers from large companies, they often mention having a frontend tier and a backend tier. So sometimes, I might hear that they have a frontend with C# and a backend with Java. Why would any company want a backend and frontend in different languages? Does this help the large website scale better?

When people say that their frontend is built in C#, does this mean that they are using a framework for the frontend (like .NET) and an additional framework on the backend (such as Spring)? Or does it mean something entirely different?

答:
An example of a back end language is PHP, which is a scripting language.
When a PHP page is requested, the server reads the PHP code and renders the markup.
 The result is HTML that is sent to you. You, the web page viewer, never see one line of PHP code.
 Assuming that the web server administrator has done his or her job correctly,
the server would, and could never show you the actual PHP code. It is parsed when the page
 is served up and the result of that code translation is HTML.</p>


答:
From some of your comments, I think Scala's Traits are a good candidate. They are basically interfaces which can contain implemented methods and can be used in lots of nice ways.

For example having a trait and a class:

```<code>trait Foo {
  def bar = println("I'm a thing that's Foo, which means I can Bar")
}
class Doodle {}
</code>```

Will let you execute a series of statements:

```<code>var foodoodle = new Doodle with Foo
foodoodle.bar
</code>```

Which executes bar, printing "I'm a thing that's Foo, which means I can Bar".

This kind of addresses your comment about a "Winged" property giving an object a fly() method.

Body:
From some of your comments, I think Scala's Traits are a good candidate. They are basically interfaces which can contain implemented methods and can be used in lots of nice ways.

For example having a trait and a class:

trait Foo {
  def bar = println("I'm a thing that's Foo, which means I can Bar")
}
class Doodle {}

Will let you execute a series of statements:

var foodoodle = new Doodle with Foo
foodoodle.bar

Which executes bar, printing "I'm a thing that's Foo, which means I can Bar".

This kind of addresses your comment about a "Winged" property giving an object a fly() method.


问:
Should I ask/tell my boss before freelancing?
I am currently working as an intern at a consulting firm. I am soon to move to a full time employee once I graduate next semester, and I love working there. However, as a student, I lack money and I have met a business owner outside of work who has offered to hire me for some freelance web development.

Because I met this individual outside of work, I feel it would not be a conflict of interest to freelance for him. However, the work his is wanting me to do is very similar to what I already do for my current boss.

Should I speak with my boss before considering the offer?

Edit: I understand that I cannot take IP from work, and I am not in a contract, I'm employed at will.

答:
Firstly, honesty never hurt anybody.

Secondly, depending on where you are based your local laws will have a big impact. In most western society with a legal system derived from UK common law, the master/servant principle still effectively applies.

The impact of this in practice is that your employer owns your output. The TIME OF DAY at which your output is produced is completely irrelevant to this. Normally, employers will take the reasonable line that stuff you do that is not relevant to their business is of no interest to them.

However they can quite rightly take the view that things you do that are in the same line of business are their property - whether done at home in the evenings or otherwise. In general if this is a hobby they won't care. But if done for commercial gain, they will care a lot. This looks and smells like a conflict of interest and is a good way to get fired very quickly.

Sometimes this will all be carefully considered and written into an employee handbook, or your contract, and sometimes it won't. If its not in your contract - whoopee doo! The law of the land still applies.

When in doubt, ASK.


问:
Good Practice : Storing variables and classes names in database for direct call
I would like to know if this is a good practice to store variables and classes names in database to use let users accessing them.

For instance users may create entries in database's table in which they can insert a program's function name that would executed when the program will read it.

I find it is a dangerous practice since users may execute or access any data of the program, but I've been told it's a quite common practice in languages with introspection like Python.

Moreover, i was also suggested to have field in a table that would store another table field's name, to create somehow a dynamic foreign key.

I personally find both practices very bad since in first case there is no more separation between user data and program data, and for the second case there is no separation between structure and data in the database.

Can you please confirm me these practices are discouraged or tell me I'm wrong and suggest me a way to approach them in a safer way.

Thank you.

答: Microsoft stores meta-data about SQL Server objects in a database. However, this meta-data is not intended for the use of anyone except a database admin who is supposed to be expert enough not to mess with it directly.  So while there can be a valid case for storing such data in a database for system use, the case for allowing a typical user access to it and the ability to change it without understanding what that means is far more risky. It is the worst of all worlds if your users are not typical expert level sys admins or DBAs or developers themselves.   Further, code should be in source control and having it there and in the database means it will get out of synch. And the whole idea of some type of dynamic FK strikes horror into my mind no matter how it is implemented as that is a recipe for data integrity problems. </p>


问:
DI / IoC Abstract Factory Galore
Given a project architecture as follows, where each box represents an assembly (all are class libraries), and each arrow stands for a dependency:

Might be worth nothing that this project is massive (well, it will become!), the complexity incurred by such decoupling is absolutely warranted.

Business Logic Layer

The BLL library defines and organizes various sets of POCO interfaces in its Abstract namespaces, and implements various functionality logic in its Concrete namespaces; the functionality logic refers to and uses the abstract POCO interfaces.

Data Access Layer

The DAL library implements the POCO interfaces from the BLL using partial classes that "extend" Linq to SQL (dbml) classes, so if there's a Customer L2S class, it implements the BLL ICustomer interface. Sometimes the L2S class has different types, or the BLL abstraction uses enum types, but most often the partial class code looks like this:

```<code>public partial class SomeEntity : ISomeEntity { }
</code>```

This assembly provides the Model, by exposing classes named "xxxxModel", which are constructor-injected with repositories regrouped into services, but there's a twist: the "xxxxxModel" classes implement an interface called IUnitOfWork which encapsulates a database transaction that must be able to operate on all repositories at its disposal... possibly with a dynamic (runtime-determined) connection string. To achieve this, I created "model factories" which create a single DataContext of the appropriate type, and inject the same instance in each repository.

Presentation Logic Layer

Some of the BLL POCO interfaces need a "ViewModel" implementation (e.g. to display as items in a list) - the PLL library defines them; however the goal of this library is more focused around, well, the actual presentation logic, although there is no reference to WPF whatsoever (other than a single reference to WindowBase but I'll get to that). So this assembly provides the ViewModel.

One thing to note is that the ViewModel here, completely controls the View - each ViewModel is injected with an implementation of IViewFactory that creates an IView implementation - technically the ViewModel is blissfully unaware of the implementations, so I'm not sure how deeply it violates MVVM (to be honest I don't really care about that point - especially after reading a blog post like this one), but the thing to point out is that it's the ViewModel that litterally creates the View and assigns the DataContext. This makes it very simple to deal with things that should be simple, such as showing and closing a window.

So all ViewModel classes inherit ViewModelBase, which is an abstract class that takes a IViewFactory in its protected constructor, effectively instantiating the View. Here's the offending code:

```<code>/// <summary>
/// An interface for a ViewModel.
/// </summary>
public interface IViewModel : INotifyPropertyChanged
{
    /// <summary>
    /// Notifies listener that the value of the specified property has changed.
    /// </summary>
    void NotifyPropertyChanged<TProperty>(Expression<Func<TProperty>> property);

    /// <summary>
    /// Notifies listener that the value of the specified property has changed.
    /// </summary>
    void NotifyPropertyChanged(string propertyName);

    /// <summary>
    /// Closes the view.
    /// </summary>
    void Close();

    /// <summary>
    /// Displays the view.
    /// </summary>
    void Show();

    /// <summary>
    /// Displays the view (modal) and returns a <see cref="DialogResult"/> value indicating how the view was closed.
    /// </summary>
    DialogResult ShowDialog();
}
</code>```

So a ViewModel essentially controls a View up to the point of encapsulating it, which makes it easy to implement my own DialogResult enumeration (much closer to the way WinForms had it).

Views Assembly

Because this library references and consumes ViewModels from the PLL assembly which implement interfaces defined in the BLL assembly, an arrow is missing here - there's also a dependency upon the BLL, but it's only used indirectly. This library provides the View, by defining WPF/XAML windows and controls.

Apart from IValueConverter and other MarkupExtension implementations, there's not much C# code in this library, the hard references to ViewModel implementations are all in XAML d:DataContext {d:DesignInstance...} declarations.

So, what's wrong?

I definitely like the direction of the dependencies, including the PLL/Views one. The fact that the BLL has zero dependencies mean I can reuse that library and come up with a WebUI if I ever need one (and that WILL happen... eventually!), and the DAL/BLL decoupling means parts of the data model could be coming from Web services, some cloud, or whatever - business logic couldn't care less and that's good.

The main issue I'm having, is that I find myself writing LOTS of abstract factories, and implementing even more of them, and I'm not always reusing these abstractions (hence the smell), but it seems to me like whenever I ask myself how I can inject a "dynamic" dependency, the answer is almost automatically - "an abstract factory will do!"... which is probably right, it's just that I don't think it's right that pretty much everything is a "dynamic" dependency!

```<code>public class SomeViewFactory : IViewFactory
{
    public IView Create(IViewModel viewModel)
    {
        return new SomeWindow {DataContext = viewModel};
    }
}

public class SomeRepositoryFactory : DataRepositoryFactory<SomeEntity>
{
    public IRepository<SomeEntity> Create(DataContext context)
    {
        return new SomeRepository(context);
    }
}
</code>```

I even have an abstract IFunctionalityFactory:

```<code>public interface IFunctionalityFactory
{
    IFunctionality Create();
}

public class SomeFunctionalityFactory : IFunctionalityFactory
{
    private readonly IFunctionalityAuth _auth;
    private readonly ISomeBusinessLogic _logic;

    public SomeFunctionalityFactory(IFunctionalityAuth auth, ISomeBusinessLogic logic)
    {
        _auth = auth;
        _logic = logic;
    }

    public IFunctionality Create()
    {
        var canExecute = auth.IsCurrentUserAuthorised(typeof(SomeFunctionality).FullName);
        return new SomeFunctionality(canExecute, _logic);
    }
}
</code>```

Is it normal to have factories for almost everything - from repositories to services and models in the DAL, to Views and ViewModels in the PLL/View library? For now the project is rather small and I'm still the only programmer working on it; I'd like to have an architecture as SOLID and simple as possible when it comes to implementing new functionalities.

This is only my 2nd project implementing DI/IoC, needless to say I'm trying to run (and swim, and perhaps even fly) before I can walk...

Any tips or issues I'm not seeing? Am I abusing Abstract Factory? How else could I instantiate a View? How else could I have a data model that could connect to any of a given set of [almost] identical databases, at the user's discretion? I know I'm breaking MVVM, have I overlooked anything in the pattern that could simplify my existence?

答:
It seems you're struggling trying to create objects that create objects... wouldn't you be better off just creating objects ?

Ninject allows you to do so in a very simple way :

```<code>// Ninject module
Bind<IRepository<SomeEntity>>().To<SomeEntityRepository>();

// injected class
public class SomeService
{
  public SomeService(IRepository<SomeEntity> repository)
  {
    // ...
  }
}

// get instance of injected class
var someService = kernel.Get<SomeService>();
</code>```

I can't see the benefit of an abstract factory in addition to an IoC container when you're creating objects based on basic, compile-time-known constraints such as in your SomeViewFactory and SomeRepositoryFactory examples.

The dynamic nature of SomeFunctionalityFactory would be more debatable, but when you think of it, do you really need to instantiate an object with the built-in notion that it will never be able to be used by the current user ? Wouldn't it make more sense to have the object evaluate user authorization when the functionality is called ?

Title: DI / IoC Abstract Factory Galore

Body:
It seems you're struggling trying to create objects that create objects... wouldn't you be better off just creating objects ?

Ninject allows you to do so in a very simple way :

// Ninject module
Bind<IRepository<SomeEntity>>().To<SomeEntityRepository>();

// injected class
public class SomeService
{
  public SomeService(IRepository<SomeEntity> repository)
  {
    // ...
  }
}

// get instance of injected class
var someService = kernel.Get<SomeService>();

I can't see the benefit of an abstract factory in addition to an IoC container when you're creating objects based on basic, compile-time-known constraints such as in your SomeViewFactory and SomeRepositoryFactory examples.

The dynamic nature of SomeFunctionalityFactory would be more debatable, but when you think of it, do you really need to instantiate an object with the built-in notion that it will never be able to be used by the current user ? Wouldn't it make more sense to have the object evaluate user authorization when the functionality is called ?


问:
Using two versions of a class in the same code
At my job, in our core project, we have a Validation class that has been evolving with the years. And ee have an old project with an User class that uses an old version of the Valdiation class.

And we have to update some functionality that requires new validation methods. All those methods are implemented in our latest Validation class.

But the new Validation class isn't backwards compatible, so we can't just put the new one in place.

I thought that a good solution would be to upgrade all the code that references the Validation Class or making it backwards compatible but, obviously, both of them would take a lot of time.

Finally, it was decided that adding the latest version and calling it Validation2 works just fine, some methods use Valdiation and others Validation2. I think that will bring a lot of problems later, because you don't know when to use one or another as the names stop being meaningful.

What could be a better option to deal with this?

Also, the Validation class was the best example, but we have the same problem with a lot of bigger and more complicated classes and now we have a lot of "duplicated" classes.
The language is PHP, but could happen in other languages too.

答:
If the classes represent different concepts (in this case they are different agents that perform different tasks), they must have different names.

In your place I would give them different names that represent particularities of their natures. Not only a version number, but a meaningful name (you already pointed out why).

Besides, I would create a superclass and make this two validators to descend from it, a validator taxonomy comes to exist.

As time passes, I would work to replace the old validators by the new ones until the old one becomes unused, then I would remove it from the code.


答:
If you're time constrained, then the solution you came up with sounds workable, albeit a bit kludgy. It sounds like you've created some technical debt and you'll eventually want to go back and clean it up.

Another option would be to create a "ValidationAdapter" class that handles translation from the old-style to new-style validation rules. Or it could just use both versions internally. The main benefit is that it keeps your main class cleaner; but it is also a short-term solution.

If the new Validaton class is supposed to supersede/replace the older one, then I'd say it's worth the time to refactor the code in question to make it work. Hopefully you've got your code under test; that makes it relatively easy to deal with. Otherwise you'll come back to the code later and kick yourself for making such a "mess."

Most languages have features to make it easier to deprecate older code. Doing so in your older validator might help you clean it out of your codebase and eventually get rid of it. I'm not sure the best practice for PHP off-hand, but I did find this stack overflow question.

Title: Using two versions of a class in the same code

Body:
At my job, in our core project, we have a Validation class that has been evolving with the years. And ee have an old project with an User class that uses an old version of the Valdiation class.

And we have to update some functionality that requires new validation methods. All those methods are implemented in our latest Validation class.

But the new Validation class isn't backwards compatible, so we can't just put the new one in place.

I thought that a good solution would be to upgrade all the code that references the Validation Class or making it backwards compatible but, obviously, both of them would take a lot of time.

Finally, it was decided that adding the latest version and calling it Validation2 works just fine, some methods use Valdiation and others Validation2. I think that will bring a lot of problems later, because you don't know when to use one or another as the names stop being meaningful.

What could be a better option to deal with this?

Also, the Validation class was the best example, but we have the same problem with a lot of bigger and more complicated classes and now we have a lot of "duplicated" classes.
The language is PHP, but could happen in other languages too.


答:
The better solution is to put unit tests on all of your classes, and keep all projects - even old projects - up to date.

If the effort of keeping a project up to date exceeds the value of that project, kill it.

Note that you will always be under pressure to just leave keeping things up to date.  But that costs more in the long run - a lot more.


问:
What Is The Formula for the 3 of 9 Bar Code Alphabet?
Background:
3 of 9 Barcode Alphabet

A simple syntax for 3 of 9 bar codes

What is the formula behind the alphabet and digits in a 3 of 9 bar code?

For example, ASCII has a relatively clear arrangement. Numbers start at 33, capitals at 65, lowercase at 97. From these starting points you can infer the ASCII code for any number or letter. The start point for each range is also a multiple of 32 + 1.

Bar codes seem random and lacking sequence. If we use the syntax from the second link, this is the first six characters in 3 of 9:

```<code>A 100-01
B 010-01
C 110-00
D 001-01
E 101-00
F 011-00
</code>```

I see no pattern here; what is it? I'm as much interested in the designer's intended pattern behind these as I am in someone devising an algorithm of their own that can give you the above code for a given character based on its sequence.

I struggled with where to put this question; is it history, computer science, information science? I chose Programmers because a StackExchange search had the most barcode hits here, and because I wanted to specifically relate it to ASCII to explain what sort of formula/explanation I'm looking for.

Update

For the curious, here's the full list of all basic characters in Code 39: http://jsfiddle.net/b9chris/LnX2e/2/

(the source lines are taken from my C# barcode lib)

You'll notice that the simplified syntax proposed can confuse the issue a bit, because it might imply that every character is a 5-bit number with a dash position. The final 4 characters have numerous dashes (wide gaps). Really, these codes are best thought of as 9-bit numbers that happen to have most odd bits set to 0 for the majority of symbols. Here they are as 9-bit numbers: http://jsfiddle.net/b9chris/LnX2e/1/

答:
The Wikipedia page you link to mentions that

Their original design included two wide bars and one wide space in each character, resulting in 40 possible characters.

As a reference it cites David Allais' memoirs:

I proceeded to illustrate a symbol character using the
  side of the chalk to draw the wide bars. The structure of five bars and four spaces
  including two wide bars and one wide space came to me in flash. The two of five coding
  in the bars afforded ten combinations and the wide space provided for four separate
  groups.

So with that in mind we can identify the marked bars and spaces and a pattern does emerge:

```<code>  BSBSBSBSB     BB S
  001122334

0 000110100     23 1
1 100100001     04 1
2 001100001     14 1
3 101100000     01 1
4 000110001     24 1
5 100110000     02 1
6 001110000     12 1
7 000100101     34 1
8 100100100     03 1
9 001100100     13 1

A 100001001     04 2
B 001001001     14 2
C 101001000     01 2
D 000011001     24 2
E 100011000     02 2
F 001011000     12 2
G 000001101     34 2
H 100001100     03 2
I 001001100     13 2
J 000011100     23 2

K 100000011     04 3
L 001000011     14 3
M 101000010     01 3
N 000010011     24 3
O 100010010     02 3
P 001010010     12 3
Q 000000111     34 3
R 100000110     03 3
S 001000110     13 3
T 000010110     23 3

U 110000001     04 0
V 011000001     14 0
W 111000000     01 0
X 010010001     24 0
Y 110010000     02 0
Z 011010000     12 0
- 010000101     34 0
. 110000100     03 0
  011000100     13 0
* 010010100     23 0
</code>```

Note that the bars for 0 in the first section correspond instead to 10 in the other three sections. If we rotate the bars to be ordered 40123 then the pattern we see is

```<code>    40123
04  xx...
14  x.x..
01  .xx..
24  x..x.
02  .x.x.
12  ..xx.
34  x...x
03  .x..x
13  ..x.x
23  ...xx
</code>```

which is one of the obvious ways of enumerating pairs of 5 elements.

Equivalently, if you name the bits B1-S3-B2-S0-B3-S1-B4-S2-B0 from left to right in your representation and instead represent each code as SBB indices then the sequence 12..90AB..YZ-. * becomes 010 020 021 030 031 032 040 041 042 043 110 120 ... 342 343.

Body:
The Wikipedia page you link to mentions that

Their original design included two wide bars and one wide space in each character, resulting in 40 possible characters.

As a reference it cites David Allais' memoirs:

I proceeded to illustrate a symbol character using the
  side of the chalk to draw the wide bars. The structure of five bars and four spaces
  including two wide bars and one wide space came to me in flash. The two of five coding
  in the bars afforded ten combinations and the wide space provided for four separate
  groups.

So with that in mind we can identify the marked bars and spaces and a pattern does emerge:

  BSBSBSBSB     BB S
  001122334

0 000110100     23 1
1 100100001     04 1
2 001100001     14 1
3 101100000     01 1
4 000110001     24 1
5 100110000     02 1
6 001110000     12 1
7 000100101     34 1
8 100100100     03 1
9 001100100     13 1

A 100001001     04 2
B 001001001     14 2
C 101001000     01 2
D 000011001     24 2
E 100011000     02 2
F 001011000     12 2
G 000001101     34 2
H 100001100     03 2
I 001001100     13 2
J 000011100     23 2

K 100000011     04 3
L 001000011     14 3
M 101000010     01 3
N 000010011     24 3
O 100010010     02 3
P 001010010     12 3
Q 000000111     34 3
R 100000110     03 3
S 001000110     13 3
T 000010110     23 3

U 110000001     04 0
V 011000001     14 0
W 111000000     01 0
X 010010001     24 0
Y 110010000     02 0
Z 011010000     12 0
- 010000101     34 0
. 110000100     03 0
  011000100     13 0
* 010010100     23 0

Note that the bars for 0 in the first section correspond instead to 10 in the other three sections. If we rotate the bars to be ordered 40123 then the pattern we see is

    40123
04  xx...
14  x.x..
01  .xx..
24  x..x.
02  .x.x.
12  ..xx.
34  x...x
03  .x..x
13  ..x.x
23  ...xx

which is one of the obvious ways of enumerating pairs of 5 elements.

Equivalently, if you name the bits B1-S3-B2-S0-B3-S1-B4-S2-B0 from left to right in your representation and instead represent each code as SBB indices then the sequence 12..90AB..YZ-. * becomes 010 020 021 030 031 032 040 041 042 043 110 120 ... 342 343.


问:
Feature code + infrastructure code - how to structure the commits / JIRA issues?
Say that you work on a feature described by a single JIRA ticket and during the work, you:

Create feature-specific code like the GUI or specific use-case behavior.

Some of the code was generic so you placed this infrastructure code in a shared library.

As an example (deliberately simple), say that the ticket is about changing a message somewhere in the application and that the message should contain the current year somewhere in it. So you first amend your PHP code where the message is and also create a helper function getCurrrentYear() in your DateUtils library.

What is the best practice now to store these changes to a source code repository and assign those code changes to JIRA ticket(s)? (Assigning commit to a JIRA ticket means in our case adding a tag to a commit message, for instance "Implemented feature #123".)

As I see it, there are these main options:

Create one commit and assign in to the given JIRA ticket.

Create two commits (one for the use-case logic and one for the infrastructure code). Assign both of them to the single JIRA ticket.

Assign only the feature-specific commit to the JIRA issue and leave the other unassigned (when viewing the ticket in JIRA, only the first commit will be visible in the "source code" tab).

Similar to 3 but you have a generic ticket like "Infrastructure improvements".

Is there a best practice / recommended way? What are some of the benefits and problems of the various possibilities?

答:
Since you're using JIRA, consider authoritative guidance provided in its documentation.

Use case you describe is intended to be addressed by sub-tasks, which purpose is described as follows:

Sub-task issues are useful for splitting up a parent issue into a number of smaller tasks that can be assigned and tracked separately. This can provide a better picture of the progress on the issue, and allows each person involved in resolving the issue to better understand what part of the process they are responsible for...

I used this feature a lot, for the purposes like you described (code targeting different aspects related to some bugfix / feature request) and in my experience, these were working very well.

One relatively minor complication I often encounter, and that you might also find worth keeping in mind, is also pointed in the documentation of JIRA sub-tasks, along with guidance on how to handle it:

Sub-tasks cannot have sub-tasks of their own. However, if you need to break up a sub-task into smaller sub-tasks, you could achieve this by first converting the sub-task to a standard issue. You would then be able to create sub-tasks for it.

Regarding commits, when using sub-tasks you rather need to find out which way feels more convenient by trial and error. There's no one size fits all approach here. Such experimenting with various approaches could be rather painless if your VCS / JIRA integration allow to edit commit message and re-upload repository.

Side note any decent VCS / JIRA plugin should allow you that. If your doesn't, consider switching to better one, because with it you would have much harder problems than optimal assignment, any typo in commit message (feature #12 instead of #123, or missing #) would break things badly.

In my experience "natural mapping" of commits to respective sub-tasks has been typically convenient.

If your integration supports having more than one issue ID in commit message, this gives you additional options to experiment with. Eg to me, in some issues it was more convenient to supply parent/sub-task pair of IDs in commit messages (I've been using Fisheye), like

commits for first subtask go as

parent #123 sub-task #124

commits for second subtask go as

parent #123 sub-task #125

etc...

That way, subtask-specific commits are visible in subtasks, while parent issue displays all commits. This was useful infrequently though, in most issues I dealt with, straightforward mapping to sub-tasks was sufficient.


问:
How do you educate your customers?
Customers need some education because they think different. Customers think:

changes are not a problem in any time of the project

details are not important (exceptions even less)

time does not cost money (they have a fix price agreed)

one sentence in the specification can be extended/read freely to fit the actual needs - and this does not affect the contract. (here we see often the "common sense" discussion - example: "Of course we need a invoice management screen when we talk about accounting managment - this is common sense!")

the list goes on...

The main problem is that customer (no matter if external or internal/department) do not want or can not understand. It took me many years to understand software creation process and I am still learning, so how can they in just a few months.

What is your experience, what is the best approach to educate customers?

答:
If you have a fixed price contract you need to make it clear that every scope change will cost money, and they you will evaluate the change and present a costed quotation for implementing the change.

This is widely accepted practice in most industries but some customers will get very upset by this.

If sounds like you have a bigger problem though if you have "common sense" being argued.

A little like a customer many years ago where I worked who read the specification and said things like "There is an IMPLICIT REQUIREMENT that you do XXX"). To which the answer was: There are no implied requirements. The only requirements are the ones in the written specification. If you want to add or change requirements, please submit a specification change request and we will quote the scope change.

The message eventually got through but it took a long time.

Title: How do you educate your customers?


问:
Am I covered with GPL If I want to share open source code of project developed in my company?
I'm working in a company and in my job contract there are confidential clauses concerning code, documents, etc...

In the company we are working on an open source project (GPL V3). The project is not shared yet to the public.

Do I have the right to share the code of the project with people (out from the company)?

答: Just because something is open source does not mean you can freely distribute it to anyone you want to. The GPL, and other licenses, are permissions granted to end users. In the case of the GPL, it grants end users the right to look at, use, and modify the software how they see fit. If the software is not distributed to someone as an end user, the GPL doesn't apply.</p>


答:
No, unfortunately, you do not have that right.

Technically, you won't have the "right" to share the code, even after the product is distributed out to the public.  The company will at that time incur a legal obligation to release the source code to anyone who requests it.

Now, what you CAN do is politely lobby your management to "do what's right" and release your company's changes back to the original project.  You do this by pointing out, diplomatically, that the availability of the GPL project in the first place saved the company a LOT of money, in that they didn't have to develop the whole thing from scratch, and this is a way for them to say "Thank you" to the original developers, and to "pay it forward" and encourage others to do the right thing.

Title: Am I covered with GPL If I want to share open source code of project developed in my company?

Body:
I'm working in a company and in my job contract there are confidential clauses concerning code, documents, etc...

In the company we are working on an open source project (GPL V3). The project is not shared yet to the public.

Do I have the right to share the code of the project with people (out from the company)?


问:
What is the best way of storing date?
I am a new to storing dates based on time zones.

Need to know the standard way to store the date in the datastore.

My requirements are

Easy to query the date based on the date range.

show the date with the client appropriate time zone selected by him(I am having a table maintained for the timezone separately)

Able to query using the datastore Admin console also.

Any suggestions/ideas regarding this will be a great help in proceeding further.

答: You might consider always storing the times in UTC. Then have your code logic handle conversions per timezone appropriately. IMO this is easier than trying to convert to other arbitrary timezones, and many code libraries have built-in options for UTC. This also has the benefit of still working if your data storage (database?) server is ever moved to a new location -- or even the cloud.</p>

Title: What is the best way of storing date?


答:
You very likely do not have the right to distribute the code.

The GNU Project's GPL FAQ has this to say on the topic:

Is making and using multiple copies within one organization or company “distribution”?

No, in that case the organization is just making the copies for itself. As a consequence, a company or other organization can develop a modified version and install that version through its own facilities, without giving the staff permission to release that modified version to outsiders.

However, when the organization transfers copies to other organizations or individuals, that is distribution. In particular, providing copies to contractors for use off-site is distribution.

If someone steals a CD containing a version of a GPL-covered program, does the GPL give him the right to redistribute that version?

...If the version in question is unpublished and considered by a company to be its trade secret, then publishing it may be a violation of trade secret law, depending on other circumstances. The GPL does not change that. If the company tried to release its version and still treat it as a trade secret, that would violate the GPL, but if the company hasn't released this version, no such violation has occurred.

Assuming you are an employee, you have received the code as an agent of the company and not as an individual. Thus, the company has not yet participated in an act of distribution (as the GPL defines "distribution"), so the rights of the GPL have not been granted to you personally. You only receive rights under the GPL when you are the recipient of a distribution.

If you really want to distribute this code, talk to your manager or company's legal department to ask for some kind of approval to release the code. Expect the answer to be a resounding "no" unless you have a compelling business argument for why the code should be released.

Addendum: what about after the company starts distributing the code to clients?

Once your company distributes the software to any clients outside of itself, it would seem the nothing has really changed for you. As long as you are not one of the clients that participates in a GPL software distribution, you continue to have the same access you did before (i.e., still an agent of the company, not a recipient of a distribution), and it would appear that the same rules apply.

The only thing that seems to change once any distribution has occurred is detailed in this GPL FAQ entry:

If someone steals a CD containing a version of a GPL-covered program, does the GPL give him the right to redistribute that version?

If the version has been released elsewhere, then the thief probably does have the right to make copies and redistribute them under the GPL, but if he is imprisoned for stealing the CD he may have to wait until his release before doing so.

Several issues here:

In the best case, sharing the code would still violate your employee contract, even if your actions are permissible under the GPL, acting in the role the thief from the above example. You've entered into a contract not to share your company's code, regardless of whether you have a legal right to do so otherwise. You will get fired and may face legal action.

This particular FAQ entry might assume "has been released elsewhere" to mean the software is generally available. However, if your company only distributes its code to a few trusted associate companies, who have no interest in sharing their copies, then a different conclusion may apply.

Even in this example, I'm not sure by what legal mechanism the thief is granted GPL rights. The victim never willingly participated in a distribution, and some comments below note that this situation means that neither the thief nor any of his recipients have grounds to sue if their GPL rights are violated, e.g., they don't get a corresponding copy of the source. Whatever legal mechanism is at play here (assuming this FAQ entry is correct -- I've never seen any case law to confirm or deny it) may not apply to you as an employee who already has access to the code.

I'm not a lawyer, this is hardly legal advice. If you're seriously interested in the answers here, talk to a lawyer.


答:
The GPL requires the company to make the source code available to anyone that the company distributes the product to. It does NOT have to make it available to anyone else. And the company is well within it's rights to refuse to distribute to anyone else.

The ONLY way that it's OK for you to distribute the source generally is if the company is distributing the PRODUCT generally. Of course, the better way to proceed in that case is for the COMPANY to distribute the source along side the product and be done with it.

Note that even if you satisfy the legalities, if you distribute source that your company wants hidden, I guarantee you'll be out of a job.


问:
Code formatting SQL queries
Should I break SQL queries in different lines? For example in the project I am working on, we have a query that is taking 1600 columns! 1600 + tab chars. I wrote queries like this:

```<code>   "SELECT bla , bla2 , bla FROM bla " .
     "WHERE bla=333 AND bla=2" .
      "ORDER BY nfdfsd ...";
</code>```

But they demanded me to put them in one line and said that my style is bad formatting. Why it is bad practice?

答:
It seems this is specifically about defining a big query inside a programming language of sorts, seeing you put the query inside a string literal and concatenate it.

If it's a compiled language, it should make no difference at all - one of the first optimizations the compiler would do is to automatically concatenate the string literals together, so you end up with a big string anyways.

As for the syntax, you should actually consider moving the query outside of your code - store it in a separate .sql resource file, and have your software read that file. Use prepared statements for the variables, if it's not a query that's built dynamically (i.e. where-clauses etc added depending on certain parameters). If it is built dynamically, you could add in replacement variables of your own, inserting extra parameters where and when needed.

As for the 1600 columns, I seriously recommend building a view for that, so instead of

```<code>SELECT column1, column2, .... column1600 from X where Y
</code>```

you'd get

SELECT * FROM viewX WHERE y

Much more concise in your own code.

Title: Code formatting SQL queries

Body:
It seems this is specifically about defining a big query inside a programming language of sorts, seeing you put the query inside a string literal and concatenate it.

If it's a compiled language, it should make no difference at all - one of the first optimizations the compiler would do is to automatically concatenate the string literals together, so you end up with a big string anyways.

As for the syntax, you should actually consider moving the query outside of your code - store it in a separate .sql resource file, and have your software read that file. Use prepared statements for the variables, if it's not a query that's built dynamically (i.e. where-clauses etc added depending on certain parameters). If it is built dynamically, you could add in replacement variables of your own, inserting extra parameters where and when needed.

As for the 1600 columns, I seriously recommend building a view for that, so instead of

SELECT column1, column2, .... column1600 from X where Y

you'd get

SELECT * FROM viewX WHERE y

Much more concise in your own code.


问:
Using a Directory Service instead of a Database
I've just started working on an existing application that uses an LDAP directory service as its object store instead of a database. Many of my coworkers have been commenting how an application should never use a directory service instead of a database as its object store. I've got to work on it regardless, and won't be able to change it from LDAP to a database anytime soon.

That said, my coworkers comments brings up the question in my mind: Why is it bad to use a directory provider instead of a database as an object store? Could there ever be cases where this would not only acceptable, but even better than using a database?

答:
A directory is a database, although one you don't use SQL to access. So, just call it a NoSQL database and you're cool again!

The only constraint would be that on a directory the data structures (the schema) are fixed, so they might not be adequate for most cases.  But if you can express your problem space in that structure, then it could be just as good.


答:
I also use Active Directory on my corporate website. One of the benefits was that not only our staff shared for the website the same account they use to connect to Windows, but also customers themselves could seamlessly use different services outside the website itself (like be able to connect to some of our servers through Remote Desktop or use SVN, which relies on Active Directory).

Having a single source of truth is always nice, including for user accounts. I wouldn't imagine having to change once per month my Windows password, my SVN password, the password on the corporate website, and five or six other passwords which would appear if we were using different data sources for each of those systems.

This being said, I can see some drawbacks of this approach:

If you don't benefit, like in my case, from having several disparate systems linked to a single Active Directory, I don't see why would one chose AD instead of an SQL database.

One mistake in configuration, and any registered user can also access any of your machines. This is risky.

I would imagine Active Directory being slower than an average SQL database. This being said, I haven't done any profiling and benchmarking to have any evidence of this assertion.

Active Directory is a tree, with a purpose of organizing and grouping entities and assigning permissions to them. For an ordinary website which requires authentication, such structure is an overkill. A simple flat table is largely enough.

Using Active Directory is not an usual thing for a website. When you start developing it, you encounter lots of issues which are not obvious to solve, including the famous error telling that Active Directory is unwilling to process your request, because... well, it's in a bad mood today. Unit-testing the solution is not straightforward too, and there are things which can be easily missed, like the characters you should escape (given that there are two distinct lists) to avoid AD Injection.

I imagine there might be some drawbacks when it comes to configuration and deployment, even if personally, I haven't encountered any.

Title: Using a Directory Service instead of a Database

Body:
I've just started working on an existing application that uses an LDAP directory service as its object store instead of a database. Many of my coworkers have been commenting how an application should never use a directory service instead of a database as its object store. I've got to work on it regardless, and won't be able to change it from LDAP to a database anytime soon.

That said, my coworkers comments brings up the question in my mind: Why is it bad to use a directory provider instead of a database as an object store? Could there ever be cases where this would not only acceptable, but even better than using a database?


问:
Premature optimization in deciding how to optimize?
We have a class that has been properly identified for optimization. We've done the profiling and testing, and it's a problem.

Now we have two possible approaches for optimizing this class:

There is some very low-hanging fruit. We can rewrite this in a few days in such a way that the interface and results aren't changed, so we don't have to change any code that uses the class. We can see what effect this has on performance and go from there. This seems to me to be a very low risk, low investment approach.

Since we're already going to be making changes, we could go all out in our optimization. The suggested approach would implement a third-party engine and require us to change the code that uses this class, as well as transform the existing client data that is sent to the class into a format usable by the third-party engine. This may not take too much longer to code, but there would be much more testing required. This seems like a very high-risk, high-investment change and will require a lot of extra testing to make sure we don't break the calling code and don't break the existing client data.

I of course can't test ahead of time, but the second approach will probably execute more quickly and be more memory-efficient. However, I'm not sure how much faster, and I'm not sure if the extra effort will even be worth it. I'm not sure that once we made the low-risk changes, we would still consider the the code to be a valid target for optimization.

You can probably guess which approach I would rather take. I'm at odds with a coworker on this one.

So here's my question: Is the second option premature optimization despite the fact that we've already identified this code for optimization? What's the approach that should be taken in this situation?

答:
In layman's words:

I consider that option 2 would be premature optimization.

Some of the things that make me think is that the justification if vague:

You don't explain why you need to use the third party engine you mention.

You mention that "without testing it, the second approach will probably be faster". Be careful not to under-estimating the effort and the complexity of the change. Be sure to have a battery of unit tests.

"Since we're already going to be making changes". You just don't make an optimization because you might as well do it.


答:
"The second approach will probably execute more quickly" is a good sign of premature optimization.

Any optimization should be based on a guess followed by evidence  (the guess may be replaced by hard data, if any). Example:

Guess: if we merge those two loops into one, it will run faster.

Evidence: the profiling shows that the merge allowed to optimize this piece of code by 27.4%.

Conclusion: we should merge two loops.

In your case, guess-evidence pattern would be something like:

Guess: the second solution would be faster than the first alternative.

Evidence: this benchmark, as well as this one and that one, show that the second solution would be indeed faster by a factor of 1.15 to 1.70.

Conclusion: given the current requirements, the difference between the effort needed to accomplish the second solution by comparison to the first one and the expected negative consequences of each of those alternatives on the quality of code, the second solution should be chosen only if the speed factor is superior to 1.45. Do we take the risk?

You, on the other hand, are imagining that the second solution will probably be faster, without any hard data as a proof. It means that it can be faster by a factor of 5.0. Or a factor of 1.005. Or a factor of 0.6, i.e. be actually slower.

Basing your optimization decision on an assumption rather than on hard data is premature optimization.

Note that you don't have to implement both solutions and compare them: it would be too expensive. But you still have to gather at least some data about a potential optimization in a context of the programming language and compiler you use before optimizing your code.

Title: Premature optimization in deciding how to optimize?

Body:
We have a class that has been properly identified for optimization. We've done the profiling and testing, and it's a problem.

Now we have two possible approaches for optimizing this class:

There is some very low-hanging fruit. We can rewrite this in a few days in such a way that the interface and results aren't changed, so we don't have to change any code that uses the class. We can see what effect this has on performance and go from there. This seems to me to be a very low risk, low investment approach.

Since we're already going to be making changes, we could go all out in our optimization. The suggested approach would implement a third-party engine and require us to change the code that uses this class, as well as transform the existing client data that is sent to the class into a format usable by the third-party engine. This may not take too much longer to code, but there would be much more testing required. This seems like a very high-risk, high-investment change and will require a lot of extra testing to make sure we don't break the calling code and don't break the existing client data.

I of course can't test ahead of time, but the second approach will probably execute more quickly and be more memory-efficient. However, I'm not sure how much faster, and I'm not sure if the extra effort will even be worth it. I'm not sure that once we made the low-risk changes, we would still consider the the code to be a valid target for optimization.

You can probably guess which approach I would rather take. I'm at odds with a coworker on this one.

So here's my question: Is the second option premature optimization despite the fact that we've already identified this code for optimization? What's the approach that should be taken in this situation?


问:
Mono is frequently used to say "Yes, .NET is cross-platform". How valid is that claim?
In What would you choose for your project between .NET and Java at this point in time? I say that I would consider the "Will you always deploy to Windows?" the single most important technical decision to make up front in a new web project, and if the answer is "no", I would recommend Java instead of .NET.

A very common counter-argument is that "If we ever want to run on Linux/OS X/Whatever, we'll just run Mono"1, which is a very compelling argument on the surface, but I don't agree for several reasons.

OpenJDK and all the vendor supplied JVM's have passed the official Sun TCK ensuring things work correctly.  I am not aware of Mono passing a Microsoft TCK.

Mono trails the .NET releases.  What .NET-level is currently fully supported?

Does all GUI elements (WinForms?) work correctly in Mono?

Businesses may not want to depend on Open Source frameworks as the official plan B.

I am aware that with the new governance of Java by Oracle, the future is unsafe, but e.g. IBM provides JDK's for many platforms, including Linux.  They are just not open sourced.

So, under which circumstances is Mono a valid business strategy for .NET-applications?

1Mark H summarized it as: "If the claim is that "I have a windows application written in .NET, it should run on mono", then not, it's not a valid claim - but Mono has made efforts to make porting such applications simpler."

答:
Small comment to the statements in the original post. I'll argue that the TCK remains a theoretical tool allowing Oracle to claim Java is an open standard. Because if you notice, Apache Harmony have been trying to get certified as "Java" for several years now, unsuccessfully. It's clear that Oracle really isn't interested in an open source implementation apart from the one they are affiliated with and more or less control (OpenJDK), which btw. much like Mono, is not complete (i.e. no Java Web Start support) and missing some optimizations available in the closed source HotSpot implementation.

So arguably, as of 2010; (most of) Java is open source but not an open standard, while (most of) .NET is not open source but an open standard. There are exceptions of course, the DLR, IronPython, IronRuby and F# actually are open source. Mono is interesting because it provides the best of both worlds, open source implementations of open standards.


答:
I think it's fine to include low-hanging fruit outright. That is, if it takes a comparable effort and number of code lines to implement an O(n²) solution and an O(n) solution, there's no reason not to pick the better of the two.

I don't think that plunging into a massive rewrite without some profiling / evaluation is a good idea. What evidence do you have that the new approach will be faster? Do you have a testing prototype, or someone else's experience with the 3rd party engine you mention? Can you spend a day or two to make this clear, and get some hard numbers?

Is there any hard evidence that the piece you're going to optimize is an actual bottleneck? Usually ~10% of code spends ~90% of cycles; if the rest ~90% of code became twice as slow, nobody would notice. Make sure you're optimizing an actual hotspot.


答:
In my experience the best way is to assign the commit(s) to the one Jira-Ticket that caused the change. The reason for that lies in the way I use the repo-history: whenever I'm not sure about a piece of code I consult the repo-history to find out why this change was made (commit comment), or who was responsible (author) to ask him/her f2f. In your example it would be clear from the repo-history and the Jira-ticket alone why it was necessary to introduce the year.

I wrote 'commit(s)' because for me it is totally admissible to do several commits according to one ticket. For that reason I use the ticket-number as a prefix of the commit-comment.

Besides, for me the overhead of creating new subtasks and do the whole Jira-lifecycle with them would be too big.

Title: Feature code + infrastructure code - how to structure the commits / JIRA issues?

Body:
Say that you work on a feature described by a single JIRA ticket and during the work, you:

Create feature-specific code like the GUI or specific use-case behavior.

Some of the code was generic so you placed this infrastructure code in a shared library.

As an example (deliberately simple), say that the ticket is about changing a message somewhere in the application and that the message should contain the current year somewhere in it. So you first amend your PHP code where the message is and also create a helper function getCurrrentYear() in your DateUtils library.

What is the best practice now to store these changes to a source code repository and assign those code changes to JIRA ticket(s)? (Assigning commit to a JIRA ticket means in our case adding a tag to a commit message, for instance "Implemented feature #123".)

As I see it, there are these main options:

Create one commit and assign in to the given JIRA ticket.

Create two commits (one for the use-case logic and one for the infrastructure code). Assign both of them to the single JIRA ticket.

Assign only the feature-specific commit to the JIRA issue and leave the other unassigned (when viewing the ticket in JIRA, only the first commit will be visible in the "source code" tab).

Similar to 3 but you have a generic ticket like "Infrastructure improvements".

Is there a best practice / recommended way? What are some of the benefits and problems of the various possibilities?


问:
How to save during real-time collaboration
I want multiple users to edit same document. Problem I'm facing is when a new user joins, he might see an outdated document. How do I make sure that new users get most recent changes?

Some solutions I thought of:

Save on every change. I don't like this solution because it will slow things down on UI and put load on db.

When new user joins, trigger save on all other clients. After other clients saved, load document.   With this there can be inconsistency still.

Any other suggestions would be helpful.

UPDATE: After looking into suggested solution, Google Realtime API, I found out that:

Users of your app must have Google Drive and give you access to their drive. This could at best present awkward UI flow or prevent users who don't have Google Drive from using realtime feature.

All the sharing settings that are done on your side, have to be replicated for Google document.

UPDATE 2: To acoomplish the goal, I went with Google's Firebase

答:
It mainly depends on the type of your documents and how your users collaborate.

However, I would:

let all clients send unsaved changes to the server every once in a while (depends on how users work with the documents).

the server stores the deltas in the user's session (even for a fat client you need something like a session)

other clients editing/viewing the same document get those temporary changes or at least a hint that there might be so.

Advantages:

no DB updates unless someone clicks 'save'

backup for the case the client crashes (for the session-period)

your server decides how and what data to forward to which client (e.g. you can jump start the feature with just a note and later implement a more sophisticated merge and highlight)

Disadvantages:

not 'real-time' - e.g. you send every 30 secs, but someone types 3 sentences in that time.

more network traffic - dependent on your documents and collaboration

possibly large sessions

possibly high computation effort if many users collaborate and do many changes