问:
What are the disadvantages of self-encapsulation?

Background

Tony Hoare's billion dollar mistake was the invention of null. Subsequently, a lot of code has become riddled with null pointer exceptions (segfaults) when software developers try to use (dereference) uninitialized variables.

In 1989, Wirfs-Brock and Wikerson wrote:

Direct references to variables severely limit the ability of programmers to reﬁne existing classes. The programming conventions described here structure the use of variables to promote reusable designs. We encourage users of all object-oriented languages to follow these conventions. Additionally, we strongly urge designers of object-oriented languages to consider the effects of unrestricted variable references on reusability.

Problem

A lot of software, especially in Java, but likely in C# and C++, often uses the following pattern:

```<code>public class SomeClass {
  private String someAttribute;

  public SomeClass() {
    this.someAttribute = "Some Value";
  }

  public void someMethod() {
    if( this.someAttribute.equals( "Some Value" ) ) {
      // do something...
    }
  }

  public void setAttribute( String s ) {
    this.someAttribute = s;
  }

  public String getAttribute() {
    return this.someAttribute;
  }
}
</code>```

Sometimes a band-aid solution is used by checking for null throughout the code base:

```<code>  public void someMethod() {
    assert this.someAttribute != null;

    if( this.someAttribute.equals( "Some Value" ) ) {
      // do something...
    }
  }

  public void anotherMethod() {
    assert this.someAttribute != null;

    if( this.someAttribute.equals( "Some Default Value" ) ) {
      // do something...
    }
  }
</code>```

The band-aid does not always avoid the null pointer problem: a race condition exists. The race condition is mitigated using:

```<code>  public void anotherMethod() {
    String someAttribute = this.someAttribute;
    assert someAttribute != null;

    if( someAttribute.equals( "Some Default Value" ) ) {
      // do something...
    }
  }
</code>```

Yet that requires two statements (assignment to local copy and check for null) every time a class-scoped variable is used to ensure it is valid.

Self-Encapsulation

Ken Auer's Reusability Through Self-Encapsulation (Pattern Languages of Program Design, Addison Wesley, New York, pp. 505-516, 1994) advocated self-encapsulation combined with lazy initialization. The result, in Java, would resemble:

```<code>public class SomeClass {
  private String someAttribute;

  public SomeClass() {
    setAttribute( "Some Value" );
  }

  public void someMethod() {
    if( getAttribute().equals( "Some Value" ) ) {
      // do something...
    }
  }

  public void setAttribute( String s ) {
    this.someAttribute = s;
  }

  public String getAttribute() {
    String someAttribute = this.someAttribute;

    if( someAttribute == null ) {
      someAttribute = createDefaultValue();
      setAttribute( someAttribute );
    }

    return someAttribute;
  }

  protected String createDefaultValue() { return "Some Default Value"; }
}
</code>```

All duplicate checks for null are superfluous: getAttribute() ensures the value is never null at a single location within the containing class.

Efficiency arguments should be fairly moot -- modern compilers and virtual machines can inline the code when possible.

As long as variables are never referenced directly, this also allows for proper application of the Open-Closed Principle.

Question

What are the disadvantages of self-encapsulation, if any?

(Ideally, I would like to see references to studies that contrast the robustness of similarly complex systems that use and don't use self-encapsulation, as this strikes me as a fairly straightforward testable hypothesis.)

答:
There are times when it would be helpful to be able to define a data type that would hold a reference to an immutable object, but would behave as an immutable object, rather than a reference, such that code written as:

```<code>thing.foo(bar);
</code>```

would compile as a call to a static method:

```<code>classOfThing.do_foo(thing, bar);
</code>```

where the static method could then handle the case of the first argument being null in whatever manner it saw fit.  A lot of string-handling code in Java could have been cleaner if String were such a type; an uninitialized variable of type string could then behave as an empty string rather than a null reference.  Conversions between such types and Object might have been a little tricky [each such type could perhaps define a singleton object to represent the default value for instances of its type, so converting a default-valued string to type Object or String would yield a reference to String.defaultInstance, conversion of a null reference to String would yield an NPE] but such types could have made some things much cleaner.

Body:
There are times when it would be helpful to be able to define a data type that would hold a reference to an immutable object, but would behave as an immutable object, rather than a reference, such that code written as:

thing.foo(bar);

would compile as a call to a static method:

classOfThing.do_foo(thing, bar);

where the static method could then handle the case of the first argument being null in whatever manner it saw fit.  A lot of string-handling code in Java could have been cleaner if String were such a type; an uninitialized variable of type string could then behave as an empty string rather than a null reference.  Conversions between such types and Object might have been a little tricky [each such type could perhaps define a singleton object to represent the default value for instances of its type, so converting a default-valued string to type Object or String would yield a reference to String.defaultInstance, conversion of a null reference to String would yield an NPE] but such types could have made some things much cleaner.


问:
My coworker commits and pushes without testing
When my coworker thinks that there is no need for a test on his PC, he makes changes, commits and then pushes. Then he tests on the production server and realizes that he made a mistake. It happens once in a week. Now I see that he made 3 commits and and pushes with deployment to the production server within 5 minutes.

I told him few times that this is not the way how good work is done. I don't want to be rude to him again and he is in the same status with me in the company and he has worked more than me here.

I want this behavior to be punished in some way or make it unpleasant as much as possible.

Before I started, the company was deploying using antique methods, such as FTP, and there was no version control.

I forced them/us to use Git, Bitbucket, Dploy.io, and HipChat. The deployment is not automatic, someone has to login to dply.io and press the deploy button.

Now, how can I force them to not test on the production server? Something like HipChat bot can sense that there is repeated edits on the same line and send a notice to the programmer.

答:
At work, we avoid this by using Gerrit. Gerrit is a code review system that acts as a gate to your main/production Git branch which is conventionally called "master". You have code reviews, right? It sounds like you personally do them exceptionally. With Gerrit, you push to a sort of staging branch which, after you and your coworker have executed the code review process satisfactorily, Gerrit then merges to your master branch. You can even hook Gerrit to a CI server to execute unit tests before anyone gets an email to review a change. If you don't have a server you can set up a CI tool on, Codeship has a nice free plan to use as a proof of concept.

Last, of course, is to automate the production deployments only from sanctioned build products that have survived the code review and unit testing. There are some cool technologies coming up for this, which I'll not mention for fear it would be flame bait.

Go to your boss with a solution. This one applies even to you, and is a way to improve everyone's code quality, not just punish your coworker.

ContentLicense: CC BY-SA 3.0


问:
long (or bizarre) file paths
I know that (on Linux at least, with native file systems like Ext3) file paths can in theory be quite long, and PATH_MAX is often (but not always) as big as 4096 (see this; and this explains it could be longer or runtime defined!).

However, file paths are often constructed on the fly, and it not uncommon in C to code something like

```<code>#define MY_PATH_MAX 256
char pathbuf[MY_PATH_MAX];
snprintf (pathbuf, sizeof(pathbuf), "%s/%s", getenv("HOME"), somevar);
FILE *f = fopen(pathbuf, "r");
//// etc, avoiding error checks for simplicity
</code>```

Now, I believe that having MY_PATH_MAX  being not too big (in particular to avoid consuming a lot of space on the call stack frame) is practically important and sensible. So, in the above example doing #define MY_PATH_MAX PATH_MAX would be silly (no need to spend 4Kbytes in my call frame).

I'm coding since 1974 and I never met a case where a file path was larger than a screen width, e.g. 80 characters or so. All the file systems I heard about did not have very deep directory hierarchy (a file with 8 directories above it is very unusual).

So, is my intuition correct? Does real software care about such long or bizarre file paths? Likewise, I never met any file name containing a newline (and I strongly recommend against spaces in file names!).

IIUC, you won't be able to build a GNU software like GCC in a directory whose name contain spaces or newlines... very likely autoconf related scripts would suffer.... Also, there is simply no way to give in your /etc/passwd  a $HOME containing newline or even a colon : -since passwd(5) does not support it.

Is my practical limit of 256 bytes in a file path a good limit?

Per the comments, I just upgraded it to 384...

Do you have a practical example where long file path names are relevant? I'm mostly interested in POSIX or Linux systems!

答:
Don't make users hate you: allow whatever the underlying system is likely to allow.

I recall running into file path problems in a reasonably large business in which assets (of several types, for products which contained content subdivided components) were stored in a folder structure that went something like:

Department name

Team name

Product family name

Product name

Release name

Component

Sub-component

Asset type

That's eight levels not including an identifier for the network drive and filename. Virtually none of these would be close to eight characters. Release name might include a date; product names would often be be of the order of "Inspirational Product Title Mark 3 Client Manual (Swiss German)".

And that's optimistic: very often another level or two of hierarchy would creep in.

Title: long (or bizarre) file paths


答:
I am very opposed to building unnecessary restrictions into our software, unless we really are in a very resource-constrained environment (e.g. embedded systems). Whenever we think that “nobody is ever going to need that”, somebody will certainly run into these arbitrary restrictions.

A maximum path length is fundamentally at odds with the hierarchical, tree-oriented, recursive model of modern file systems. A path addresses a node in this tree, and there should be no fundamental difference in addressing between a tree and its subtree. Yet imposing a length limit on the overall path means that in extreme cases we can address a file from a subdirectory that can't be addressed from a parent directory. E.g. if our path lengths were limited to ten bytes, to address the file /a/b/c/d.txt (12 bytes + terminator), we could chdir into /a/b and then address the file as c/d.txt. Having to chdir just to open a file really sucks.

In practice, long path names can occur due to a variety of reasons:

File systems are a database. Some programs use hashes as key in this database, e.g. Git or Firefox. while both are very tame as they only use fairly short paths such as ./.git/objects/07/5f3cb2c7deb3abb3ce6b7e6eb8b83ff34c883c (relative path, 56 bytes + terminator) or ~/.cache/mozilla/firefox/********.default/cache2/entries/1101BEDA093DDE5562CCC4FE6CF1C4538D36022E (relative path, 97 bytes + terminator), there is no reason why someone shouldn't have multiple hashes in a path.

Many programming toolchains use long paths. For example, Java has a convention where a package name such as com.example.product.awesome.backend.dataaccesslayer.util can lead to a path ./src/com/example/product/awesometool/backend/dataaccesslayer/util/SecondaryProductInformationVisitorManagerFactory.java (facetious example, relative path, 120 bytes + terminator). I ran a query on my file system to find the longest path, and it turned up a file in a NodeJS package called /usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-js/node_modules/browserify/node_modules/insert-module-globals/node_modules/combine-source-map/node_modules/inline-source-map/node_modules/source-map/lib/source-map/indexed-source-map-consumer.js (real example, no symlinks, 298 bytes + terminator). Though I have to admit, that appears to be a horrible project layout.

Symlinks are fun. Especially when they are at the end of a long path and point to a directory. Of course, symlinks have real uses, e.g. for configuration management.

I'd strongly suggest to get away from a fixed-size mindset. Scale as needed, since one size doesn't fit all. If you don't want to allocate a 4KB buffer on the stack, then don't. Your example in the question is particularly bad because you can easily find out how much space you need, and simply malloc that much – or use variable length arrays, if your compiler allows. If it turns out that someone has passed you megabytes of data, you can explicitly fail with that reason, but trying to access a half-copied filename is even worse. I think Steele and Sussman have put it better than me in their 1979 “Design of LISP-Based Processors or, SCHEME: a Dielectric LISP or, Finite Memories Considered Harmful or, LAMBDA: The Ultimate Opcode” memo:

As far as the LISP programmer is concerned, new data objects are available in endless supply. They can be conveniently called forth to serve some immediate purpose and discarded when they are no longer in use. […]

The immense freedom this gives the programmer may be seen by an example taken from current experience. A sort of error message familiar to most programmers is “too many nested DO loops”, or “more than 200 declared arrays” or “symbol table overflow”. Such messages typically arise within compilers or assemblers which were written in languages requiring data tables to be pre-allocated [at compile time] to some fixed length. The author of a compiler, for example, might well guess, “No one will even use more than, say, ten nested DO loops; I'll double that for good measure, and make the nested-DO-loop-table 20 long.” Inevitably, someone eventually finds some reason to write 21 nested DO loops, and finds the compiler overflows its fixed table and issues an error message (or worse yet, doesn't issue an error message). On the other hand, had the compiler writer made the table 100 long or 1000 long, most of the time most of the memory space devoted to that table would be wasted.

Of course, they are talking about early Fortran and its aversion to dynamic memory management. The irony here is that C absolutely does support dynamic memory allocation, although it is admittedly cumbersome. If you need some help to keep track of all that memory, you can always use C++…

Title: long (or bizarre) file paths

Body:
I know that (on Linux at least, with native file systems like Ext3) file paths can in theory be quite long, and PATH_MAX is often (but not always) as big as 4096 (see this; and this explains it could be longer or runtime defined!).

However, file paths are often constructed on the fly, and it not uncommon in C to code something like

```<code>#define MY_PATH_MAX 256
char pathbuf[MY_PATH_MAX];
snprintf (pathbuf, sizeof(pathbuf), "%s/%s", getenv("HOME"), somevar);
FILE *f = fopen(pathbuf, "r");
//// etc, avoiding error checks for simplicity
</code>```

Now, I believe that having MY_PATH_MAX  being not too big (in particular to avoid consuming a lot of space on the call stack frame) is practically important and sensible. So, in the above example doing #define MY_PATH_MAX PATH_MAX would be silly (no need to spend 4Kbytes in my call frame).

I'm coding since 1974 and I never met a case where a file path was larger than a screen width, e.g. 80 characters or so. All the file systems I heard about did not have very deep directory hierarchy (a file with 8 directories above it is very unusual).

So, is my intuition correct? Does real software care about such long or bizarre file paths? Likewise, I never met any file name containing a newline (and I strongly recommend against spaces in file names!).

IIUC, you won't be able to build a GNU software like GCC in a directory whose name contain spaces or newlines... very likely autoconf related scripts would suffer.... Also, there is simply no way to give in your /etc/passwd  a $HOME containing newline or even a colon : -since passwd(5) does not support it.

Is my practical limit of 256 bytes in a file path a good limit?

Per the comments, I just upgraded it to 384...

Do you have a practical example where long file path names are relevant? I'm mostly interested in POSIX or Linux systems!


问:
What would you consider best practice workflow tools for web application (PHP) development?
I'm really hoping somebody with more experience can edit the question as per my examples of answers:

using version control

test driven development

debugging code (xdebug for php)

use of UML diagrams

use of OOP for maintainable, reusable code

use of frameworks (like Zend Framework for php) for rapid application development

Anything else or an elaboration of what I mentioned above?

Basically, I'm in the middle of forming a team of developers (I'm a developer myself) and I'd like some advice on how professional programmers/designers etc should work together and what standards/paradigms they should use.

Also, if anybody has any books or links on the subject I'd welcome that!

I did find this which I guess satisfies what I'm looking for, or at least part thereof:

http://www.ibm.com/developerworks/websphere/library/techarticles/0306_perks/perks2.html

答:
Version Control
Since you're working in a team it's in your best interest that you go with something distributed. Your candidates are Git and Mercurial. This means your team can commit locally without breaking the project, but still track their work, then push these commits to the central server. It's also much faster and has fewer merge conflicts since the code is tracked as change sets rather than revisions. Read though the hginit guide (written by the co-founder of stack overflow no less) and you'll understand a bit more about what a DVCS is.http://hginit.com/

You should also use the repository for deployment instead of rsync or ftp.

Test Driven Development
Depending on what you are doing testing can waste a lot of time. I'm not saying you should completely skip it, for smaller projects it's overhead. If you are writing a library or large long-term project, sure write tests for it. The tests will help in the maintenance phase. Be aware that TDD can't find all your bugs. There will be user experience problems, layout problems, performance problems and so on.

Debugging
Xdebug is basically your only choice here. It integrates well with Netbeans.
If you feel the need to ever print variables out you should use a log file. Use the frameworks log function, this is much safer in production.

Planning / Diagrams
If you are using a good framework you shouldn't need to make detailed diagrams too much. Keep it simple and work in shorter release cycles, it's easy to over-plan. The requirements and specifications of a project are bound to change so I wouldn't spend all your time on them. Remember that code IS specification at the most detailed level.

Use your bug tracking tool (see below) to break the specification up into tasks which you can assign to team members. Use a central tool to document the projects, the bug tracker will probably have a wiki.

You can use a tool like Mysql Workbench to design database schemas in diagrams and export them as SQL.

Frameworks and OOP
This is probably the most important part. Find yourself a popular framework which will support rapid development and code reuse.
Some people won't like me saying this, but a framework should dictate the way you work. It should provide structure so one developer can switch project and know exactly where the controller for a certain page is, exactly what the template variables are and how to query the model. Some frameworks allow too much flexibility here and you'll find that developers don't always use the framework in the same way. I like the python philosophy; there should be one obvious way to do everything.
This is why I like django and rails, they are quite opinionated and this means I can look at someone elses code and understand what it does. Symfony looks like the best option here, but I would checkout Rails (Ruby) and Django (python) anyway, it might be exactly what you need.

There are many 'what framework' questions on stack overflow like this one:
https://stackoverflow.com/questions/2648/what-php-framework-would-you-choose-for-a-new-application-and-why

Bug Tracking
Get your team a good bug tracker which is made for developers. Don't use something over simplified like basecamp. Redmine and Unfuddle are two examples of excellent bug trackers, they can also track time and integrate with your repositories. Your team should use this tool to communicate on issues rather than email or IM. It makes it easier for a new developer when there is an existing history of bugs and docs available.
This article explains exactly what any good bug tracker needs to do and why. http://www.joelonsoftware.com/articles/fog0000000029.html

ContentLicense: CC BY-SA 2.5


问:
workflow tips & tricks for managing incomplete and not-yet functioning code?
I do web app development and bash scripting and I usually work on several projects at once in different contexts and languages and often return to a project after a few months absence.

When I return to a project there are always fragments of code that are incomplete and I have trouble "re-familiarising" myself with what I was doing and what I was trying to acheive.

I use version control and can look at the history, but that only gives a backward look at what happened in the past.

Regarding outright breaking code

I use version control "topic" branches to isolate any code that outright breaks functionality, Im more struggling with trying to understand the  state of affairs of the little bits of incomplete, but "non-breaking" work.

Does anyone have any suggestions on how I might manage these items in a "forward looking" way? , possibly along the lines of

TODO's

issues in github/bitbucket

commenting out code

have the code run an alert -  in the app - to say I need to be finished

write unit test definitions which explains what you are trying to achieve - even if the unit test wont be written till later

etc

答:
Each new feature should have an issue in your tracker. Whenever you're working on the feature, keep the issue open in a browser window.

Before you start work on the feature, map out what you think you need to do to make the feature work. Check them off (but don't delete them) as you complete them. Keep adding to this list when you see new things, before you start coding.

Some issue trackers let you track to-do items or even nested issues. Use whatever's appropriate to the scope, but remember you need to be able to quickly drop in and add your todo in the issue.

That way when you return to the issue you can see progress, outstanding work blockers, etc. at a glance before you decide to restart, without you having to dig up your code and analyse it.

Other things you might consider:

git hooks which will look for the string "todo" and refuse to commit if any are present

See if your testing suite supports to-do items like Perl's Test::More

write explanatory code comments and commented-out code lines differently so you can grep for them separately (e.g. make all your comment lines begin //:: or #~)


答:
Does real software care about such long or bizarre file paths?

There is no such thing as a long or bizarre file path.  There are only valid and invalid file paths, and real software -- correct software -- sees the valid ones as strings of bytes and doesn't care about the contents.

Is my practical limit of 256 bytes in a file path a good limit?

Absolutely not.  Nor is your revised limit of 384.

The practical limit on any system that defines PATH_MAX is PATH_MAX whether the actual value behind it is 5, 50, 500 or 5,000.  (256 is the minimum required by POSIX.)

PATH_MAX is the system's way of telling you exactly how many characters to expect in a valid path.  Using buffers that are any smaller limits your program to being able to handle a subset of the valid paths on the system.  That will serve to aggravate users of your program that run afoul of this limitation and makes more work for you when they ask that you adhere to the established standard.

Unless you can describe a specific, actual problem that is solved by using truncated buffers, there's no reason to be using anything other than PATH_MAX.  The 1970s were over 35 years ago, and PATH_MAX bytes for a path on most stacks isn't an issue.  If you're in a stack-constrained environment, odds are good you're probably not going to be opening a lot of files, and if you are, that environment's PATH_MAX will be something small enough to accommodate it.

Title: long (or bizarre) file paths


问:
How should I handle incompatible configurations with the Builder pattern?
This is motivated by this answer to a separate question.

The builder pattern is used to simplify complex initialization, especially with optional initialization parameters).  But I don't know how to properly manage mutually exclusive configurations.

Here's an Image class.  Image can be initialized from a file or from a size, but not both.  Using constructors to enforce this mutual exclusion is obvious when the class is simple enough:

public class Image
{
    public Image(Size size, Thing stuff, int range)
    {
    // ... initialize empty with size
    }

    public Image(string filename, Thing stuff, int range)
    {
        // ... initialize from file
    }
}
```

<p>Now assume <code>Image</code> is actually configurable enough for the builder pattern to be useful, suddenly this might be possible:</p>

<pre class="lang-java prettyprint-override"><code>Image image = new ImageBuilder()
                  .setStuff(stuff)
                  .setRange(range)
                  .setSize(size)           // <----------  NOT
                  .setFilename(filename)   // <----------  COMPATIBLE
                  .build();
</code>```

These problems must be caught at run time rather than at compile time, which isn't the worst thing.  The problem is that consistently and comprehensively detecting these problems within the ImageBuilder class could get complex, especially in terms of maintenance.

How should I deal with incompatible configurations in the builder pattern?

答:
You've got your Builder.  However, at this point you need some interfaces.

There is a FileBuilder interface that defines one subset of methods (not setSize) and a SizeBuilder interface that defines another subset of methods (not setFilename).  You may wish to have a GenericBuilder interface extend the FileBuilder and SizeBuilder - it is not necessary though some people may prefer that approach.

The method setSize() returns a SizeBuilder.  The method setFilename() returns a FileBuilder.

The ImageBuilder has all the logic for both setSize() and setFileName().  However, the return type for these would specifiy the appropriate subset interface.

class ImageBulder implements FileBuilder, SizeBuilder {
    ImageBuilder() {
        doInitThings;
    }

    ImageBuilder setStuff(Thing) {
        doStuff;
        return this;
    }

    ImageBuilder setRange(int range) {
        rangeStuff;
        return this;
    }

    SizeBuilder setSize(Size size) {
        stuff;
        return this;
    }

    FileBuilder setFilename(String filename) {
        otherStuff;
        return this;
    }

    Image build() {
        return new Image(...);
    }
}
```

<p>One special bit here is that once you have a SizeBuilder, all of the returns need to be SizeBuilders.  The interface for it looks like:</p>

<pre class="lang-java prettyprint-override"><code>interface SizeBuilder {
    SizeBuilder setRange(int range);
    SizeBuilder setSize(Size size);
    SizeBuilder setStuff(Thing stuff);
    Image build();
}

interface FileBuilder {
    FileBuilder setRange(int range);
    FileBuilder setFilename(String filename);
    FileBuilder setStuff(Thing stuff);
    Image build();
}
</code>```

Thus, once you call one of those methods, you are now unable to call the other and create an object with an invalid state.

Body:
You've got your Builder.  However, at this point you need some interfaces.

There is a FileBuilder interface that defines one subset of methods (not setSize) and a SizeBuilder interface that defines another subset of methods (not setFilename).  You may wish to have a GenericBuilder interface extend the FileBuilder and SizeBuilder - it is not necessary though some people may prefer that approach.

The method setSize() returns a SizeBuilder.  The method setFilename() returns a FileBuilder.

The ImageBuilder has all the logic for both setSize() and setFileName().  However, the return type for these would specifiy the appropriate subset interface.

class ImageBulder implements FileBuilder, SizeBuilder {
    ImageBuilder() {
        doInitThings;
    }

    ImageBuilder setStuff(Thing) {
        doStuff;
        return this;
    }

    ImageBuilder setRange(int range) {
        rangeStuff;
        return this;
    }

    SizeBuilder setSize(Size size) {
        stuff;
        return this;
    }

    FileBuilder setFilename(String filename) {
        otherStuff;
        return this;
    }

    Image build() {
        return new Image(...);
    }
}

One special bit here is that once you have a SizeBuilder, all of the returns need to be SizeBuilders.  The interface for it looks like:

interface SizeBuilder {
    SizeBuilder setRange(int range);
    SizeBuilder setSize(Size size);
    SizeBuilder setStuff(Thing stuff);
    Image build();
}

interface FileBuilder {
    FileBuilder setRange(int range);
    FileBuilder setFilename(String filename);
    FileBuilder setStuff(Thing stuff);
    Image build();
}

Thus, once you call one of those methods, you are now unable to call the other and create an object with an invalid state.


问:
How to design a relational database for user following other users?
I want to design my relational schema to store information about users following other users. So if user1 is following user2 the schema will be as below

```<code>user_follow
------------
|user1|user2| -> Column names
------------
|U_Nm1|U_Nm2| -> tuple
------------
</code>```

So in this way if user1 is following 100 other users I will have 100 rows just for a single user. If I have lots of users following lots of other users my table size will grow enormously. Is there any other way I can design this? I know it is better to use NoSQL for such requirements but I am restricted to use Relational DB.

答:
I know it is better to use NoSQL for such requirements

I'm not sure why you'd think that.  After all, question data is very relational in nature.

Here's what I'd do:

User table

UserId (primary key)

UserName

... etc ...

Following table (join table)

FollowingUserId (foreign key to UserTable.UserId)

FollowedUserId (foreign key to UserTable.UserId)

Utilizing this join table you'll be able to create a "following" relationship between users.  And sure, if a user follows 100 users, then yes there will be 100 rows in the join table for that single user.  That is small in reality, though, and with optimizations there would be negligible impact.


问:
Is feature ownership a good practice?
Recently in my company it has been suggested that one developer should focus (and only one) in one feature. That would mean something like setting the developer aside of the normal team routine, releasing it of some other responsibilities (meetings and such) and this person would be the "only" responsible for the feature, technology wise.

For the record, we use SCRUM within SAFe, and we have for full time developers per team, sharing QA and product owners between our two teams (Android and iOS).

While I agree that this would increase productivity in a short term, I have the feeling (and I think I learned it in the university) that this is a bad practice for many reasons:

Code review loses value.

Minimal knowledge sharing.

Risk increment.

Loss of team flexibility.

Am I right or it's not a bad practice at all?

答:
In my 20 years of experience, it is better to have code ownership rotate responsibilities amongst designers or at least have a pair of owners. Single feature ownership has the following issues, several of which you mentioned:

it tends to pigeon hole designers and limit their growth opportunities

it puts all the eggs in one basket so if someone is hit by a bus or quits, there can be a hole in knowledge

a single person may not see an issue in the code and without a peer owner code reviews are far less effective

it is hard to maintain code consistency and readability if everyone is working on code using their own style - while this can be worked around with style guidelines, subtleties can creep in especially when using convention over configuration where people are relying on default behavior

developers can tend to become protective and defensive of their code if they own it which can inhibit evolution of code - if several people own it, this tendency is reduced

Title: Is feature ownership a good practice?


问:
Do I have to distribute my commercial source code that links GPL software if I only use this commercial software to provide a reporting service?
At my company we created proprietary software that we use only internally - we do not distribute this software - to generate reports from client data. We sell these reports to our clients, not the software.

If we were to link to GPL licensed software from our software, would will still need to (upon request) provide our proprietary source code?

I understand that if we distributed our proprietary software itself, the answer would be yes. And I understand that if we used the proprietary software only for internal purposes, the answer is no (e.g., see discussion here). But if we only use the proprietary software internally, in order to generate a report product that we do sell (distribute) to customers, then what is the answer? This link seems to suggest probably not, but what if the GPL software creates a particular image that is displayed on one page in a many-page report?

Thanks in advance for some clarity on this. Legalese is so hard for me to understand, but if you could also point me to the particular sections of the GPLv3 that make this clear, I'd appreciate it.

答:
The fact that a tool was used to produce some output does generally not give the copyright holder of the tool any rights to the output to the tool. For example, Microsoft has no rights at all to the documents that you create with Microsoft Word.

There are some rare cases of tools where copyrighted parts of the tool are included in the output. That's very rare. Obviously you can check that with your documents. If the software prints "Page 1" nobody would consider that they have a copyright on that, even if the "Page" is the direct copy of the word "Page" somewhere in the copyrighted source code.

There are applications with licenses that restrict use of the output. An example was a quite successful compiler for MacOS which came in a paid version and a free version for students - both versions were identical, except that the free version explicitely did not allow making money from the output of the compiler. So you could use the free version to build a product, but when you sold it for millions you had to buy the paid version.


答:
What's the worst that could happen? Do you have backups that are good enough so that a bug modifying random records in your database can be fixed by restoring an old version?

Let's say you have a bug where you use a record id, and by mistake the amount of a bill in cents is stored in a variable used for the record id. So if I pay $12.34 then the record with id 1234 will be modified. Can you recover from that, if the software runs for a few hours until the bug is detected? (If both the correct record and record 1234 are updated, you would only detect this when record 1234 is used, so this could go undetected for quite a while).

Now ask your highly motivated developer what he thinks about this. Obviously he cannot claim that he never makes mistakes, because he has done so in the past.

Title: My coworker commits and pushes without testing

Body:
When my coworker thinks that there is no need for a test on his PC, he makes changes, commits and then pushes. Then he tests on the production server and realizes that he made a mistake. It happens once in a week. Now I see that he made 3 commits and and pushes with deployment to the production server within 5 minutes.

I told him few times that this is not the way how good work is done. I don't want to be rude to him again and he is in the same status with me in the company and he has worked more than me here.

I want this behavior to be punished in some way or make it unpleasant as much as possible.

Before I started, the company was deploying using antique methods, such as FTP, and there was no version control.

I forced them/us to use Git, Bitbucket, Dploy.io, and HipChat. The deployment is not automatic, someone has to login to dply.io and press the deploy button.

Now, how can I force them to not test on the production server? Something like HipChat bot can sense that there is repeated edits on the same line and send a notice to the programmer.


答:
Feature ownership is inevitable, and done well can be a good thing. It help builds mastery and allows autonomy - two of the generally recognized pillars of engagement. It makes it clear who has the accountability for that code, and aids in delegation, communication, and otherwise getting shit done.

But you're not talking about that. You're talking about making a new team of one - cutting this person off from the rest of the code. That is not great. It limits their career. It adds risk to the project/company. It harms comradarie.

So some moderation might be in order to turn this away from a bad idea.

Title: Is feature ownership a good practice?

Body:
Recently in my company it has been suggested that one developer should focus (and only one) in one feature. That would mean something like setting the developer aside of the normal team routine, releasing it of some other responsibilities (meetings and such) and this person would be the "only" responsible for the feature, technology wise.

For the record, we use SCRUM within SAFe, and we have for full time developers per team, sharing QA and product owners between our two teams (Android and iOS).

While I agree that this would increase productivity in a short term, I have the feeling (and I think I learned it in the university) that this is a bad practice for many reasons:

Code review loses value.

Minimal knowledge sharing.

Risk increment.

Loss of team flexibility.

Am I right or it's not a bad practice at all?


问:
Is there any programming language(s) which has mathematical number types?
I may not have worded the title correctly. Is there any programming language(s) which deals with natural mathematical number types rather than the typical data types we see like Int32, Int64, Float, Double etc?

By natural number types I mean the likes of

natural (1, 2, 3 ...)

whole (0, 1, 2, 3 ...)

integer (-1, 0, 1, 2, 3 ...)

rational (-1, 0, 1, 1.25, 2, 3, 3.5 ...)

real (-1, 0, 1, 1.25, 2, 3, pi, 3.5 ...)

complex (-1, 0, 1, 1.25, 2, 3, pi, 3.5, i, 2i, 1 + 2i ...)

Or may be bit more practical and useful set of types, like

whole (0, 1, 2, 3 ...)

integer (-1, 0, 1, 2, 3 ...)

real (-1, 0, 1, 1.25, 2, 3, 3.5 ...)

complex (-1, 0, 1, 1.25, 2, 3, pi, 3.5, i, 2i, 1 + 2i ...)

so that if I write:

whole w = 1 // compiles

integer i = 1.2 // doesnt compile

real r = 1.2 //compiles

complex c = 1 + i //compiles

w = i //doesnt compile

i = w //compiles

r = i //compiles

c = r //compiles

I know I can achieve this in most programming languages using uint32, int32, decimal etc types but I'm looking forward to a language that doesn't appear that technical about numeric types.

Few points:

Looking for programming languages which names the numeric types from a mathematical perspective and not computer.

I know size always matter in programming, but let's assume size is not an issue for now. Or may be it is configurable and I could set the size to be as that ofuint64, int64 etc. This is more than ever needed.

I am not after math libraries which has types defined like real, complex etc. I want those types to be treated as first class by compiler/language itself so that static error checking is done.

Asking this just out of curiosity when I was thinking of programming languages for educational purposes for non-programmer friend.

答:
The real and complex numbers are uncountable. Regardless of what representation you choose, almost all of them cannot be stored on anything that could be considered a computing device. The closest you can get is the computable numbers, but testing two computable is undecidable. Even disregarding that, it's not a very practical representation. Some sort of multi-precision floating point numbers, or arbitrary precision rational number, is the most general practical option — despite only supporting (a subset of) the rational numbers. Naturals and integers are common though, arbitrary precision integer arithmetic is supported in many languages, quite a few of them use them as default type (or transparently upgrade to it when overflow would occur).

Now, as for static type checking: You rule out libraries, but "static error checking" is equally possible for library types. You just don't get convenient numeric literals. There are a few languages that allow user-defined literals.

There might be languages that subscribe to the particular set of numeric types and implicit conversions you propose, but it's a rather odd bunch. Are you dead set on these specifics? Many high-level languages such as Python, Ruby, and various Lisp dialects have arbitrarily large integers and floating point and complex numbers built in, and occasionally also rational numbers. They are not statically typed though. Likewise, most statically typed languages default to fixed-sized types. Haskell might be close, including overloading integer literals though I don't think complex numbers can have 4i syntax.

NB: What you call "whole numbers" are usually called the natural numbers. Some mathematicians exclude 0 from the natural numbers, but equally many (and all computer scientists) include it. The integers are the whole numbers.


答:
FORTRAN, is close.  It has INTEGER, REAL, COMPLEX. REAL explicitly has 2 different precision lengths. COMPLEX cannot be negative.

Looking for programming languages which names the numeric types from a mathematical perspective and not computer.

Fortran  is especially suited to numeric computation and scientific computing.

Some mathematicians exclude 0 from the natural numbers, but equally many (and all computer scientists) include it.

Zero is to computer programming as The Big Bang is to AstroPhysics. ... Just a thought.

Title: Is there any programming language(s) which has mathematical number types?

Body:
I may not have worded the title correctly. Is there any programming language(s) which deals with natural mathematical number types rather than the typical data types we see like Int32, Int64, Float, Double etc?

By natural number types I mean the likes of

natural (1, 2, 3 ...)

whole (0, 1, 2, 3 ...)

integer (-1, 0, 1, 2, 3 ...)

rational (-1, 0, 1, 1.25, 2, 3, 3.5 ...)

real (-1, 0, 1, 1.25, 2, 3, pi, 3.5 ...)

complex (-1, 0, 1, 1.25, 2, 3, pi, 3.5, i, 2i, 1 + 2i ...)

Or may be bit more practical and useful set of types, like

whole (0, 1, 2, 3 ...)

integer (-1, 0, 1, 2, 3 ...)

real (-1, 0, 1, 1.25, 2, 3, 3.5 ...)

complex (-1, 0, 1, 1.25, 2, 3, pi, 3.5, i, 2i, 1 + 2i ...)

so that if I write:

whole w = 1 // compiles

integer i = 1.2 // doesnt compile

real r = 1.2 //compiles

complex c = 1 + i //compiles

w = i //doesnt compile

i = w //compiles

r = i //compiles

c = r //compiles

I know I can achieve this in most programming languages using uint32, int32, decimal etc types but I'm looking forward to a language that doesn't appear that technical about numeric types.

Few points:

Looking for programming languages which names the numeric types from a mathematical perspective and not computer.

I know size always matter in programming, but let's assume size is not an issue for now. Or may be it is configurable and I could set the size to be as that ofuint64, int64 etc. This is more than ever needed.

I am not after math libraries which has types defined like real, complex etc. I want those types to be treated as first class by compiler/language itself so that static error checking is done.

Asking this just out of curiosity when I was thinking of programming languages for educational purposes for non-programmer friend.


问:
How do you go about understanding others' code?
What do you do to understand some code that you didn't write? Or code that you wrote long time ago and don't remember what it does anymore.

Do you have some technique that you go about? Do you analyze the structures first, or the public methods, or do you draw flow charts, etc.? Or do you fire up the debugger and just step through it? Or do you just ad-hoc your way through until you understand it?

答: Generate/draw/read a call graph.</p>

Body: Generate/draw/read a call graph.


问:
Banning zero-argument functions -- what problems could it cause in a hypothetical language?
I'm creating a programming language as a hobby, but I encountered a problem with designing its syntax. The problem is the conflict between the syntax for defining zero-argument functions and the syntax for reassignment operations. The function definition syntax is taken from Haskell, and looks like this:

```<code>name arguments = expression
</code>```

A zero-argument function would obviously have this form: name = expression. However, that poses a problem because, without context, the programmer could confuse such a definition with a reassignment operation (which has the same form, variable = expression).

My solution is simple: ban functions with zero arguments. More precisely, such functions would now take a single value of the unit type as their argument. This is inspired by Scala, where functions that "don't return anything", actually return () (of type Unit), which is a type with only one possible value that carries no useful information.

The definition would then look like this:

```<code>name () = expression
</code>```

And a call would have the form name () -- note that '()' is not a parameter list, but rather the value of type Unit. The above definition relies on pattern-matching, as () is not the name of the argument, but the only form it can take.

My question is whether such a design decision makes theoretical sense, and whether it would have some practical negative effects?

答:
Scala returning () really just means that you should ignore the meaningless return value. Basically the same as void in C, right? But a function that takes no arguments can still return a usable value, so I'm not sure I see a one-to-one correspondence in the design.

Forcing functionally parameterless functions to take a parameter of type Unit which is ignored by definition, feels really unnatural to me.

Lots of languages have survived overloading the = operator.


答:
Sure, that makes sense theoretically. Especially in functional languages, having a function that takes no input is weird. Though I would encourage you to prevent declaring parameterless functions, not prevent them in your type system.

Consider parameter binding. If you have a unary function and bind a parameter to it, you would have a parameterless function even though you did not declare it. Having a special case to add a dummy parameter seems not great (but perhaps unavoidable).

Just using a different declaration operator than the equal sign seems like it would also be a viable alternative to deal with potential confusion (though parameterless functions will have impact elsewhere in the language).

Title: Banning zero-argument functions -- what problems could it cause in a hypothetical language?

Body:
I'm creating a programming language as a hobby, but I encountered a problem with designing its syntax. The problem is the conflict between the syntax for defining zero-argument functions and the syntax for reassignment operations. The function definition syntax is taken from Haskell, and looks like this:

```<code>name arguments = expression
</code>```

A zero-argument function would obviously have this form: name = expression. However, that poses a problem because, without context, the programmer could confuse such a definition with a reassignment operation (which has the same form, variable = expression).

My solution is simple: ban functions with zero arguments. More precisely, such functions would now take a single value of the unit type as their argument. This is inspired by Scala, where functions that "don't return anything", actually return () (of type Unit), which is a type with only one possible value that carries no useful information.

The definition would then look like this:

```<code>name () = expression
</code>```

And a call would have the form name () -- note that '()' is not a parameter list, but rather the value of type Unit. The above definition relies on pattern-matching, as () is not the name of the argument, but the only form it can take.

My question is whether such a design decision makes theoretical sense, and whether it would have some practical negative effects?


问:
The Critical Functionality of an API has changed, what should I do?
What should you do if an API has changed the provided functionality? [In this case it would affect your project as a whole]

Some more context in my situation: Facebook eliminated the APIs ability to create, update, or delete event's via their API, they only provide read access. My whole application is based on creating and managing events. What should I do now? Facebook is one of the biggest platforms that my customers use. (It's great because friends can add friends)

答:
The first thing you should do is shout your favorite expletives while imagining the horrible tortures you would like to inflict on those who just killed your project. That's a great way to relieve stress and vent frustration.

After you calmed down, your next step would be to write an apology to your customers where you explain calmly and professionally that your service will unfortunately be no longer available in the future because Facebook does no longer allow that kind of access to their service, that there is nothing you or they can do about it, that they should send any complaints about this to Facebook directly and that you would be happy to have them again as customers for your next product which will be announced soon. Then you take your project offline and do a project retrospective.

When everything is wrapped up, you would take a long walk and come up with a business case for a new, completely unrelated project. This time, think carefully if it is really worth the risk to invest time and money into a product which depends heavily on a service provided by someone else who gives you no guarantee whatsoever that their API won't change or disappear without prior notice. Especially not when it is provided by a company like Facebook, which has a reputation for doing whatever they want without considering the interests of 3rd parties or even their own users.


问:
Why does Python need both a compiler and an interpreter?
I can understand the fact that Java needs both a compiler and an interpreter. It compiles source code to bytecode and then a virtual machine (on Windows, on Linux, on Android, etc.) translates that bytecode to machine code for the current architecture.

But why does Python need both a compiler and an interpreter? Since Python is not platform independent, why not just use interpretation? As far as I know, you cannot execute a Python program (compiled to bytecode) on any Windows or Linux machine without modification. Or am I wrong?

答:
I can understand the fact that Java needs both a compiler and an interpreter.

It doesn't. There's nothing in the Java Language Specification that says that Java needs to have a compiler. There's also nothing in the Java Language Specification that says that Java needs to have an interpreter.

Whether to use an interpreter, a compiler, or a combination of the two, is completely left to the discretion of the implementor.

In fact, there are implementations of Java which compile straight to machine code, e.g. the GNU Compiler for Java gcj. Technically speaking, the Oracle OpenJDK Java compiler also compiles to machine code, specifically, JVM byte code. Now, you might say, wait a minute, that's not machine code! But, there are software interpreters for x86 machine code, and there are hardware CPUs that can execute JVM byte code, so what makes one "native" and the other not?

Note that JVM byte code sits outside of the Java Language Specification, just like x86 machine code does.

and then a virtual machine (on Windows, on Linux, on Android, etc.) translates that bytecode to machine code for the current architecture.

Again, that is purely up to the implementor.

The original Sun JVM did never translate, it always interpreted. The current Oracle OpenJDK JVM interprets, and only those parts which get executed often are compiled. The Maxine Research VM always JIT compiles. The Excelsior.JET implementation compiles once, ahead of time. The IKVM.NET JVM compiles to CIL byte code. The Android Runtime compiles ahead-of-time, once, during installation. (Also, the Android Runtime doesn't understand JVM byte code, it uses Dalvik byte code, which is a completely different language.)

But why does Python need both a compiler and an interpreter?

Again, it doesn't. There is nothing in the Python Language Specification that says that Python needs to have a compiler. There is also nothing in the Python Language Specification that says that Python needs to haven an interpreter.

Note that actually, Python is never interpreted. All existing Python implementation always compile Python to a different language. That language may or may not then, in turn, get interpreted, but that language is a different language from Python. Python doesn't get interpreted.

why not just use interpretation?

Because Python isn't designed to be easily interpreted by machines. It is designed to be easily interpreted by humans. OTOH, CPython byte code, is designed to be easily interpreted by machines. So, it makes sense to write code in a language designed for humans and interpret in a language designed for machines, and in order get from one to the other, you have to compile.

As far as I know, you cannot execute a Python program (compiled to bytecode) on any Windows or Linux machine without modification.

Yes, you can. The CPython VM is available for both Windows and Linux, as is PyPy, Jython and IronPython.

Languages don't have to be compiled or interpreted. Languages just are. In fact, a language can perfectly exist without having any interpreter or compiler! For example, Konrad Zuse's Plankalkül which he designed in the 1930s was never implemented during his lifetime. You could still write programs in it, you could analyze those programs, reason about them, prove properties about them … you just couldn't execute them. (Well, actually, even that is wrong: you can of course run them in your head or with pen and paper.)

Now, any particular implementation of a language may use a compiler (or even multiple compilers), an interpreter, or any combination. But that is a trait of the implementation, not the language. Every language can be implemented with a compiler, and every language can be implemented with an interpreter.

Note, however, that you can't run a program without an interpreter. A compiler simply translates a program from one language to another. But that's it. Now you have the same program, just in a different language. The only way to actually get a result of the program is to interpret it. Sometimes, the language is an extremely simple binary machine language, and the interpreter is actually hardcoded in silicone (and we call it a "CPU"), but that's still interpretation.

You might also be interested in this answer of mine, which explains the differences and the different means of combining interpreters, JIT compilers and AOT compilers and this answer dealing with the differences between an AOT compiler and a JIT compiler.


答:
I see this as a largely human problem - the process is there and the tools are there, but the process is just not being followed.

I agree with what others have said here, about the possibility that it's quite possible the developer in question is just stuck in an SVN mindset, and may well think that he is following the process.

I find that the best way to address this kind of issue, especially where there may not be a clear superior, does not revolve around punishment or removal of access - this just leads to resentment and as it sounds like you are the loud proponent of following the process (there's always one, and I've been 'that guy' before), you're the one likely to cop the most heat. It revolves around bringing people to agreement on the process first.

This is where structured meetings, like "lessons learnt"-type meetings after a major incident in production, can be very useful. Try getting everyone to agree, including the developer in question, that code review, unit testing, comprehensive testing, etc. all need to take place, every time (and you can start to introduce the idea of a staging environment here too). It shouldn't be hard, and it's very sensible. Then ask the team to come up with some solid rules together, on how it should be done. The more the developer who is causing the problem contributes, the more they will feel like adhering to the rules, and start to see why their behavior has been a problem.

The final point, is never to fall into the "well, it's better than it used to be!" trap. There is always room for improvement. It is common for people in the IT industry, in my experience, to start settling for what they've got, after some improvements. The settling then continues, until you're suddenly at a crisis point again.


问:
In C#, is it good practice to use implicit numeric conversions from int to float?
For example:

```<code>if(5.0f > 1) { }
</code>```

Does it have a significant performance penalty? Compared to just doing

```<code>if(5.0f > 1.0f) { }
</code>```

答:
In the examples you provided there is most probably no difference, since all the necessary conversions will most probably be performed at compile time.

The following will incur a slight performance penalty:

if( floatVariable > intVariable )

The penalty will be of the order of an additional clockcycle.  (Maybe two? three clock cycles at most? that's still of the same order.)

Is that significant?  It depends on what kind of stuff you are doing.  If you are working on some extremely computationally intensive processing software, like weather simulation models for meteorology, then it will be significant.  Barely.  If you are doing anything less intensive than that, it is a joke to be even wasting any time thinking about it.

Actually, if you fill your software with conversions between float and int, and the software you are writing is a run of the mill application, and it becomes published and it gets installed on a couple of thousand computers, and people use it every day and keep it installed for an average of one year, the time you have already wasted writing this question and reading this answer is probably more than the total amount of time that will be wasted by all of those users together, over the entire year.


答:
With respect to good design, I would suggest you should use two subclasses to Users; Followers and Followed. If you draw an ER diagram, this approach is more semantically richer.

So the schemas would be:

User (UserName, Email, etc)

FollowerUser (FollowerName, FollowerEmail, etc)

FollowedUser (FollowedName, FollowedEmail, etc)

Following (FollowerEmail, FollowedEmail)

One of the advantages of such design is that Users who are not Following or being Followed by anyone are now more easily accessible.

Moreover, database normalization or optimization is required when you want to remove redundancy. In this case:

User1 follows User2 is different from User1 follows User3, since each row represents a new relationship. Hence the data is not redundant and normalization is not required.

Title: How to design a relational database for user following other users?

Body:
I want to design my relational schema to store information about users following other users. So if user1 is following user2 the schema will be as below

```<code>user_follow
------------
|user1|user2| -> Column names
------------
|U_Nm1|U_Nm2| -> tuple
------------
</code>```

So in this way if user1 is following 100 other users I will have 100 rows just for a single user. If I have lots of users following lots of other users my table size will grow enormously. Is there any other way I can design this? I know it is better to use NoSQL for such requirements but I am restricted to use Relational DB.


问:
Short Circuit Execution
Modify the car painting example car.color = favoriteColor ||"black"; so that the car is painted with your favorite color if you have one; otherwise it is painted with the the color of your garage: otherwise it is painted red.

I am missing some functions. This is what i have:

```<code>car.color = favoriteColor || "red";
function PaintCar (favoriteCar, garage, red)
{
  //The test succeeds if the favoriteColor boolean value is true.
  if favoriteColor
  {
    return "black"
  }
  // The test succeeds if either condition is true.
  if ((favoriteColor == "black") || (garage == "grey"))
  {
    return "";
  }
  else
  {
    return "car is paint is red";
  }
}

var reaction = GetReaction(false, "red");
document.write(reaction);
//Output: Car is finished.
</code>```

答:
I think the paintCar function makes more sense if you provide a reference to the car object and the colors of the garage and favorite.</p>

```<code>function PaintCar (favoriteColor, garage, car)
{
  //The test succeeds if the favoriteColor boolean value is true.
  if (favoriteColor)
  {
    return car.color = favoriteColor
  }
  // The test succeeds if either condition is true.
  if (garage)
  {
    return car.color = garage
  }
  else
  {
    return car.color = "red"
  }
}
</code>```

Title: Short Circuit Execution

Body:
I think the paintCar function makes more sense if you provide a reference to the car object and the colors of the garage and favorite.

function PaintCar (favoriteColor, garage, car)
{
  //The test succeeds if the favoriteColor boolean value is true.
  if (favoriteColor)
  {
    return car.color = favoriteColor
  }
  // The test succeeds if either condition is true.
  if (garage)
  {
    return car.color = garage
  }
  else
  {
    return car.color = "red"
  }
}


问:
Can I include a modified GPL/Apache licensed font in my LGPL project?
I want to include a GPL & Apache duel-licensed font in my LGPL project, but didn't really find a clue if that's possible.

There are two problems here:

I didn't find any clue about Apache license's "LGPL Compatibilty". I know both the licenses involved here are compatible with GPL, but I still prefer to release the work under LGPL.

It's kind of tricky since it's a font. It was GPL & Apache duel-licensed, but the LGPL terms are asking about "Library", its "Public API", "Linking" or something. I am not really sure what the operation belongs to if I just edit a .ttf file manually, not even sure about if that's counted as "source".

Any help would be really appreciated!

答:
Let's get some basics in discussed:

SO what's a license really?
A license is essentially a set of permissions with a set of conditions. A licence allows you do things provided you adhere to certain other conditions; this in turn also implies things you can't do! For example in a commercial licenses you can use but can't distribute. In GPL you can use, modify as well as distribute but can't prevent anyone else from distributing. In fact GPL licence GPL software can't be distributed with lesser strict license i.e. it doesn't allow you publish the same software which in turn can be taken up and re-dsitributed with non-GPL licences (or any commercial licence).

SO what does a compatible licence means?

A set of license can be called compatible if terms of one doesn't contradict with other. You can think of LGPL as a pure subset GPL. i.e if you distribute the modified version of the work as source code everything mandatory as LGPL is just the same as GPL. But if you are only using some library in binary form conditions are much more relaxed. Hence it is compatible licenses. Typically one can convert it from one way to other but not vice-versa. Incidently, MIT and Apache license are much more relaxed - unlike GPL/LGPL.

SO what happens when you have two license for the same software?

Basically, a license is a choice you make to use as well as comply. Given that you have 2 license, you have 2 choices. You can choose which one applies to your
case. And that's perfectly valid legally. (DISCLIAMER: I AM NOT LAWYER). So for example if a code is available under LGPL to me, which allows me to publish my code linking with it as binary only - it is perfectly legal to do so. Now even if the same code is also distributed under GPL it doesn't matter because LGPL permissions are equally available to. Of course nothing prevents me to assume GPL conditions and permissions either; but usually whichever license works for you, you can choose.

SO why would one have dual license anyway?

If in any case, lesser of the two license is going to be applied - what's the point of the second one? A classic case is QT and other such open source yet commercial outfits. The catch is, if you pay QT - you can acquire LGPL for QT and then it can allow you to distribute your binary. However, LGPL is not available for general public - there only the more stringent GPL applies. Hence, it is also critical to note who is granted what license!

So now about your particular question:

If the font you are using was GPL (only) licenced - there is no choice but your own code has be to released under GPL. (Or of course drop that font). It can't be released.

If the font you are using was Apache (only) licensed - the only condition is the Warranty Disclaimer and Credits being granted to the original developer. In this case, you can release your code under Apache license, LGPL, GPL and even commercial license.

Since there are two licenses available, you can choose which one applies! That's it. Of course, you must validate that Apache license is applicable to you.

Hope this gives you clarity you were seeking.


问:
How did JavaScript become popular?
In ancient history, Brendan Eich had a language design, and in today's world, JavaScript is a popular language implemented and used in many different places.

What caused the language to become popular? Was it the C-like syntax familiar to previous programmers? Did Netscape have enough control of the market to force it to be used? Or is there some deeper reason that JavaScript is popular and other languages are not?

Particularly, if you had to make a language as popular as JavaScript, what initial conditions would you need to recreate its growth in popularity?

答: Hasn't is been the only cross-browser client-side scripting language? Its popularity seems to have grown in lock-step with that of the web, which makes sense.</p>

Title: How did JavaScript become popular?


问:
Is there a client license to require servers it connects to using a certain license?
Say I create both a client and a server application. The server remains secret while the client is published under a GPL-ish license, so obviously the communication protocol can be reconstructed to some degree allowing others to attempt writing their own server. I'd be fine with that, if those servers were also bound by the same (or a similar) GPL-ish license, such that only the original server were not Open Source.

Is there a license to work in such a way, i.e. that the client must not connect to any server but either mine or those licensed under a given license?

Would I have to dual-license the client in order to keep my own server "legal" if others contribute to the client?

答:
This is indeed a great question. And the reason why it is great because it moves mere copyright domain to intellectual property domain. And the moment you talk about IP - there is no one way right!

OK - in a nutshell let me rephrase this so that I know that I have understood right! Basically there are two pieces of software one is client and one is server. The user is licensed under some conditions to use the client software. The server can either be distributed or reverse engineered. But you want to control who can build such servers ever and what they can do with licenses.

There is a real case for this. CISF is a file system (involving both as Client & Server side work) that allows people to share files. The protocol was hidden by Microsoft but Linux folks reverse engineered the protocol and made SAMBA. Now you are at the position of Microsoft here (no pun here!). Now CISF is proprietary.

Do the primary party has copyright for reverse engineered servers?

No mater whatever legal depth you go to, as far as the Copyright of SAMBA's source code is considered, Microsoft doesn't OWN it. So there is no way Microsoft can control which license SAMBA uses to distribute and whether or not they make it available free or commercially. So in simple terms - whatever be the license of client, the server code can't be controlled.

Possibility beyond client & server basic interaction

The issue becomes even more tricky when a client variants and server variants are build by third party does not just what your client-server pair does but supply more functionality and hence they own those functionality as well and not you.

Who owns the intellectual property?

Now, while Microsoft would have no right over SAMBA's source code, the do own the intellectual property around CISF which is the technology making things possible. You can have a patent for this; and since you own CISF IP, you can directly apply upon anyone who use the same spec for developing either client OR server or any system that inherently use the mechanism protected against in the patent.

Practical solution

What you can do in a real world is that have server be authenticated by the client using a specific listing server. Now what you can include in the End-User-License that will prohibit them to connect to any server which are not authorized. I presume that you are controlling such authorization of listing by default. Now the crux here is that, in principle you are not making it illegal to distribute or run reverse-engineered servers. You are just making it illegal for the users to use it. This also means that if someone has a way to make a client-server pairs both -then it is perfectly legal to use that which just uses the protocol you have. So in all, for you intellectual property of protocol only patent

Applicability of patents

Even if we assume that a patent is granted to you, patent protection is only for 15 years. Also, not every country grants every nature of work as patentable. Specially software patents, algorithms and I believe that will be true for protocols are not equally patentable everywhere around the globe. But the commercial licenses are there forever binding.

ALL of the above, of course have one more underlying assumption is being able to enforce contract terms and patent claims to all parties.

Hope this helps.


答:
In most cases it is possible to put a work around in place. the users can still create events right? just not through the api. so, worst case when they click a button you can have a webpage open.

You can probably find some halfway house where you parse the webpage and partially automate the Event creation

Title: The Critical Functionality of an API has changed, what should I do?

Body:
What should you do if an API has changed the provided functionality? [In this case it would affect your project as a whole]

Some more context in my situation: Facebook eliminated the APIs ability to create, update, or delete event's via their API, they only provide read access. My whole application is based on creating and managing events. What should I do now? Facebook is one of the biggest platforms that my customers use. (It's great because friends can add friends)


问:
Pattern for communicating between nested usercontrols and parent form (C# / Winforms)
I'm trying to decide the best way to handle communication between a UserControl that is nested within another UserControl and the parent Form itself.  I have a Form, inside the form there's a UserControl with a TabControl.  Each tab in that is also represented with a UserControl.

An object (for binding) gets instantiated at the form and then passed to a property in the first UC, which then passes it on to a property on the nested UC.  Each UC uses a BindingSource to wire up the actual input controls.  This daisy chaining behavior gets to be cumbersome.  Now I want to send a Save command back to the main form, so I need to daisy-chain some events back up to the form.

I feel the entire object shouldn't be owned by the parent form at all. The object pretty much drives this entire application, but because the Form and UI was growing to be a maintenance nightmare, I started breaking up UI components into UserControls.

I guess my questions are:
- Would this be a good place for some sort of Service Locator pattern?
- Should I just keep it simple with a static singleton instance of this object that can be accessed from any control?
- Are there any other patterns that could be helpful that you could recommend?

答:
You can use the Mediator pattern.

essentially you have a single object to which you bind events and pass that into view models rather than binding to the viewmodel event. so:

```<code>public interface IMediator
{
    void NotifyColleagues(string token, object args);
    void Register(string token, Action<object> callback);
    void Unregister(string token, Action<object> callback);
}
</code>```

..in main VM

```<code>Mediator.Register("start_Click", OnStart);
</code>```

..in sub VM

```<code>Mediator.NotifyColleagues("start_Click", this.data);
</code>```

Body:
You can use the Mediator pattern.

essentially you have a single object to which you bind events and pass that into view models rather than binding to the viewmodel event. so:

public interface IMediator
{
    void NotifyColleagues(string token, object args);
    void Register(string token, Action<object> callback);
    void Unregister(string token, Action<object> callback);
}

..in main VM

Mediator.Register("start_Click", OnStart);

..in sub VM

Mediator.NotifyColleagues("start_Click", this.data);


问:
Is this the correct way to include this MIT licensed software in my software?
I'm using this script in one of my projects. It's licensed under MIT or Apache 2.

I've committed JSON.sh (as in, just the script) to my project, and copy+pasted the MIT license (as it appears in LICENSE.MIT) to the bottom of it.

Is that sufficient?

答:
It is perfectly all right. However you need to be careful.

In the whole code structure if there is only one file LICENSE.MIT, it doesn't make it clear whether it applies to only JSON.sh or other works. Hence ideally you should have your main license file (e.g. LICIENSE) which should mention that grant for JSON.sh is available through LICENSE.JSON.MIT or something like that.

If you are also extending your work under MIT license, then there is no need for duplicate effort.


问:
How to prepare for INTERVIEW with PAIR PROGRAMMING (C#)
I have a stage in an interview process where I am supposed to do pair programming, or at least they want to see me working in Visual Studio with an experienced developer.  This is a company promoting Scrum.

How should I behave?

How should I prepare?

I would think I should prepare for NUnit and perhaps MS-Test.  Are there other scenarios that are likely in a TDD/Agile environment?

(Perhaps something with Reshaper and MVC?)

答:
Having done this from both sides of the table my guess would be that they want to see you program. Likely they will have some sort of simple problem you will have to solve.

The best prep you can do is to practice. Create a solution, add class libs, test projects and an app, web/wpf/wcf write some code covering the technologies they mention in the job app, Linq, PTL, REST, whatever, ensure you write unit tests and run them etc

A good question to ask is which version of Visual Studio they are using. You don't want to get tripped up because you are used to 2010 and they are on 2013 or vice versa. Similarly, do they use resharper? if you are used to that.

During the int, talk constantly through what you are typing, do the test first and build and run frequently so you pick up on any bugs/typos, ask the interviewer how they would do it "would you use dependency injection here?" and stuff as this indicates you know about the topic without having to do it/expressing an opinion about best practice


问:
How many views and controllers do I need?
I did one AngularJs app which was rather complex, with multiple nested tabs, which had multiple nested views & controllers, needed ng-router, and was quite tricky for me to implement, as browser based coding is not my usual thing.

Now I have been asked to code something for a friend. He was to have a column of buttons down the left sized and when a button is clicked the corresponding contents should be shown on the page.

Conceptually, this seems the same as the previous project (although it is not yet clear whether there will be any nesting).

I could just have a single view, with a single controller and several
s which I can ng-hide and ng-show, but something makes me think that I ought to use multiple views & controllers, although I am not certain.

How should I implement it, and why?

答:
In general I think it is good to keep the separation of concerns in mind. Don't hesitate to create new views and new controllers. If you correctly define the responsibility of each controller, in the end your code is much easier to maintain.

In your specific case, if you haven't already, have a look at directives in AngularJS. They are pretty well explained in this course provided by Google.


问:
Is the use of a constant as a parameter of an Unit Test mocked dependency's method wrong?
We have a Unit Test Case where we want to assert that after a login operation, the SUT is able to call a method on one of it's dependencies. This dependency is a NavigationManager and the expectation is that it calls NavigationManager.NavigateTo(string).

Up to this point, we are mocking the NavigationManager to isolate the SUT. This is our test method:

```<code>var calledNavigatedToMethod = false;
nmMock.Setup(nm => nm.NavigateTo(NavigableScreens.MyNextScreen)).Callback(() => calledNavigatedToMethod = true);

SUT.Login();

Assert.IsTrue(calledNavigatedToMethod);
</code>```

As you can see, NavigableScreens.MyNextScreen is a constant, which make us think this is not a dependency, ergo it shouldn't be injected/mocked. We are merely testing that when SUT.Login()  is called, its dependency calls a method with said constant.

Our confusion is that, by the time we were writing the unit test, NavigableScreens.MyNextScreen wasn't yet defined, which made the test dependable on it's existence, and made us think that for that reason it should be injected/mocked.

A proposed argument is that since it is a dependency of the SUT, it MUST exist, which means using this constant in the Test Case is perfectly fine, as it is the exact same thing as calling NavigationManager.NavigateToMyNextScreen() in the way that if the method doesn't exist by the time the test is written, we'd have the same issue, so it MUST exist.

The question would be, is the use of this constant in the test case wrong, making it a non-unit test?

答:
If the current requirements are that after login, you must always navigate to the screen indicated by the constant NavigableScreens.MyNextScreen, then that most likely isn't a dependency that should be injected. It is just a value that you pass on to another function anyway.

However, NavigationManager looks to be a class with a fair bit of functionality in it. That is something that should be injected as a dependency into the SUT (unless your SUT is NavigationManager itself).

Given that, your unit-test is fine.

When looking at where to use mocks/stubs/fakes in your unit-tests, there are some considerations to keep in mind (besides needing DI for other purposes than testability):

Is the code that isn't strictly part of the SUT stable and well-tested enough that I am very unlikely to uncover problems with it? If not, then it should be mocked.

Are the operations performed by the extra code complex or time-consuming enough that they might affect how fast my unit-tests execute? If they are, you should mock those operations.

Are the operation performed by the extra code related to persistence? If so, they really should be mocked. When databases or other persistence mechanisms come into the picture, it becomes really hard to keep your tests independent of each other. You really want that complexity only when you are actually testing such mechanisms.


问:
Compiling vs pre-built binaries on production machine?
I referred Compiling vs using pre-built binaries performance?. The post talks about performance and opportunities for optimization.

My question is about reliability.

I built both python and postgresql from source and they are running good on my development machine. I am planning to do the same in the production environment.

Is compiling for production the same as compiling for development environment?

If not, what are the precautions I need to take?

答:
There are several tradeoffs you've made that are not immediately obvious.

By running your own builds, you're responsible for keeping track of upstream updates, particularly with regard to security.

You're also suspectible to changes in your environment that would've been handled in distribution packages, but you again have to monitor and re-integrate such modifications.

The onus is also on you to verify that your own binaries work as they should on the target platform, particularly if you've used more aggressive build settings.

Unless there are clear advantages for you (needing newer versions than the distro, site patches needed, lack of connectivity/trust), there is very little to gain from building from source yourself.


答:
There are significant risks if you build your own package.  You will need to track upstream changes and keep up to date.  (Otherwise you will miss security, functionality, and optimization changes.)

Rather than build on the production server, build on the the development server and package the software for installation on the production server. For many distributions, you can download the package source and build your own distribution package.  Do this on your development server and deploy to production.

While there are possible opportunities for optimization.  It has been my experience many optimizations actually slow performance.  You need the same hardware for development and production if you are building and testing your own packages. (Several factors can cause optimizations that work in development to fail in production and vise versa.)

If you really need a newer version in production, check for a backport version.  Even if a backport is not available, it may be possible to deploy the package from a newer OS release in the current environment.  This would be safer than build your own.  You would need to monitor the distribution for updates.

Title: Compiling vs pre-built binaries on production machine?

Body:
I referred Compiling vs using pre-built binaries performance?. The post talks about performance and opportunities for optimization.

My question is about reliability.

I built both python and postgresql from source and they are running good on my development machine. I am planning to do the same in the production environment.

Is compiling for production the same as compiling for development environment?

If not, what are the precautions I need to take?


问:
How to access a variable that I only need to create once on Application.Start
According to this guide: https://github.com/mspnp/azure-guidance/blob/master/Retry-Service-Specific.md

They say:

Note that the StackExchange.Redis client uses multiplexing through a single connection. The recommended usage is to create an instance of the client at application startup and use this instance for all operations against the cache. For this reason, the connection to the cache is made only once, and so all of the guidance in this section is related to the retry policy for this initial connection—and not for each operation that accesses the cache.

Right now I have something like this:

```<code>public static Models.UserProfile GetUserProfile(string identityname)
        {
            /// It needs to be cached for every user because every user can have different modules enabled.
            try
            {
                var cachekeyname = "UserProfileInformation|" + identityname;
                IDatabase cache = CacheConnectionHelper.Connection.GetDatabase();
                Models.UserProfile userProfile = new Models.UserProfile();
                object obj = cache.Get(cachekeyname);
</code>```

I can move the connection line to global.asax

```<code>protected void Application_Start()
        {

            IDatabase cache = CacheConnectionHelper.Connection.GetDatabase();

        }
</code>```

If I move that line, then how can I get that instance on the other methods where I need to use it?

this is the cache connection helper

```<code>public class CacheConnectionHelper
    {
        private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() =>
        {
            return ConnectionMultiplexer.Connect(SettingsHelper.AzureRedisCache);
        });

        public static ConnectionMultiplexer Connection
        {
            get
            {
                return lazyConnection.Value;
            }
        }
    }
</code>```

AS I dont know much about patterns, maybe this is a singleton? but I have no idea how to implement it!

答:
If you declare the variable in the local context of Application_Start() as you have in your example, it is only accessible in that method.

One solution could be to declare the variable as a global variable, outside of the "Application_Start()" procedure.

Example:

```<code>public class Global : System.Web.HttpApplication {

  public static IDatabase DBCache;

  protected void Application_Start(object sender, EventArgs e) {
    DBCache = CacheConnectionHelper.Connection.GetDatabase();
  }
}
</code>```

then you are able to access it from your other classes by calling it like this:

```<code>public class test {
  public myFunction() {
    var mycache = Global.DBCache;
  }
}
</code>```

Body:
If you declare the variable in the local context of Application_Start() as you have in your example, it is only accessible in that method.

One solution could be to declare the variable as a global variable, outside of the "Application_Start()" procedure.

Example:

public class Global : System.Web.HttpApplication {

  public static IDatabase DBCache;

  protected void Application_Start(object sender, EventArgs e) {
    DBCache = CacheConnectionHelper.Connection.GetDatabase();
  }
}

then you are able to access it from your other classes by calling it like this:

public class test {
  public myFunction() {
    var mycache = Global.DBCache;
  }
}


问:
How to use SOLID principles in this example
I have reading about SOLID principles last week and decided to try to solve real world problem by using them. So I got the problem of real world ecommerce site managing totals.

Problem Statement:
  We have to calculate some totals like subtotal, taxes, vouchers, coupon, total on a cart products.

So I have decided to make TotalManager which returns total_data and total to the rest of the program.

```<code>// total data variable looks like
array('key'=>value)
</code>```

e.g. array('subtotal'=>100,'total'=>150,'tax'=>50)

```<code>    class TotalManager{
        private $total_data;
        public function get_total_data()
        {
            $totals = array('subtotal','total','taxes')
            // foreach totals array gets each object check its instance of interface itotal and called it's get method.
        }
    }

    Interface Itotal
    {
        public function get_total_data();
        public function get_total();
    }

    class subtotal implements Itotal
    {
        public function get_total_data()
        {
            // it needs cart object
            // get the cart product calculate totals and return total_data and total
        }
        public function get_total()
        {
            return the subtotal in double/float
        }
    }

    class total implements Itotal
    {
        public function get_total_data()
        {
            // get the other totals object  and calls it get_total method
            // calulate sum of all totals and return
        }

        public function get_total()
        {
            // calculate total and return back;
        }
    }
</code>```

But I am facing problems in this model:

For dependency inversion principle I cannot directly create the object of cart or subtotal in subtotal, Total class respectively I have to pass them from controller at total manager.

When I think about that whenever I am adding the class I have to change the Total manager for adding the new method so it's violating open/closed principle. How to solve this in OOD?

答:
The Open/Closed principle allows you to add new methods.  You won't be able to alter the interface to existing methods.

It may be simpler to have a class that takes a cart and returns/recalculates the totals.  Try to avoid using this class to maintain state between calls.


问:
What are the differences regarding speed and functionality between using Actions vs Delegates?
I know this is a language specific question and may not be suitable here but I would like to create an array of functions that will be called based on their index and I would like to know the difference between Delegates and Actions. I am aware that with delegates you string many of them in a single one and pass values between them etc. But are there any other differences?

Also are their any differences regarding speed?

答:
An Action is just a delegate thats predefined so you don't have to make them yourself when using Linq/PTL

http://referencesource.microsoft.com/#mscorlib/system/action.cs,486d58da4553e12d


问:
Switching over to the real ES6 / ES2015
It is exciting time of having Babel and being able to use all nice nice features. It got me thinking, what happens in the future? Nobody really talks about it. I mean some browsers would eventually implement different features according to specs, some will be lacking behind.

Babel allows us to selectively disable any features thus relying on native implementation. What does that mean in reality? Are we going to end up with different builds of our applications for different versions of browsers? Is there going to be some "bootstrap" script that detects features and then tells the server what build it wants?

I suppose that currently written applications would most probably end up running just on Babel. What about the future ones? Shouldn't we think about how to overlap this gap in a development most easily?

答:
Direct answers / TL;DR

...

The future is compilation forever, compilation in more places (e.g. node), and compilation by more and more developers/projects.

Are we going to end up with different builds of our applications for different versions of browsers?

I'm just going to go with whatever large companies determine is best. They have more experience profiling, the time to commit to it, and the largest stake in having fast sites and apps.

Using multiple bundles is likely to screw with some tool or optimization that doesn't exist yet. You can do this today with user agent sniffing, or the method you suggested.

Shouldn't we think about how to overlap this gap in a development most easily?

I don't see the value proposition. Eventually features will be dropped from the compilers (generally at <1% usage). "most easily" is what we have now.

Selectively Disable any Features

Which features? If we over simplify these are the variables we need to consider.

features you use

features engine X supports

target engine compatibility

This is already pretty complicated.

Here's a diagram of how (I think) most people think this works:

However here's a better depiction of it. Way at the bottom you'll see a white section, which has 33 exceptional oddities. Scaled down from 1,440 by 15,0001:

Imagine another column for what your code uses, and another for the target options you'll use. And then you need to break it into polyfills and syntax transforms, and enable/disable each to match your requirements.

My Eternal Assumptions

you want to use features not supported in your target browsers

the size of polyfills is negligible in the grand scheme of things

initially the native version has a 3% chance of being faster than the polyfill/transform

after a year the native version has a 70% chance of being faster than the polyfill/transform

the new engine version made the polyfill/compiler output faster than the previous version

your tooling can produce faster code than it did 6 months ago, and framework specific plugins make it even faster!

this version of the spec allows for better/easier static analysis

many are using supersets of ecmascript with no intention to change that

people will micro-optimize

your micro-optimizations are wrong

your tools' micro-optimizations are eventually correct, and more likely to be maintained

we're able to run more code that ignores parallelism in parallel

writing readable obvious code is eventually faster than

Title: Switching over to the real ES6 / ES2015


答:
It's pretty simple: Netscape used a JavaScript engine in their browser. If you wanted to do scripting on the web, JavaScript was it. Internet Explorer had (and still has) both JavaScript and VBScript, but obviously if you want to work in more than just IE you have no choice but to use JavaScript.

JavaScript is a great language in its own right, but it would be nowhere near as popular today if it weren't for the fact that it's the only language you can use to script HTML.

Title: How did JavaScript become popular?

Body:
In ancient history, Brendan Eich had a language design, and in today's world, JavaScript is a popular language implemented and used in many different places.

What caused the language to become popular? Was it the C-like syntax familiar to previous programmers? Did Netscape have enough control of the market to force it to be used? Or is there some deeper reason that JavaScript is popular and other languages are not?

Particularly, if you had to make a language as popular as JavaScript, what initial conditions would you need to recreate its growth in popularity?