Tag Info

Hot answers tagged

19

This is entirely possible. Let's assume we have 35 switch-case constructs of 10 cases each, which would give us a rough cyclomatic complexity of 350 when each switch occurs one after the other. The first switch gives us 10 paths. The second switch gives us another independent 10 paths, so that we have 10ยท10 paths until here. With the third switch, we get ...


5

So if a thousand people are following Sally, we insert a thousand rows into the corresponding table. Is that scalable? Yes, provided the database tables are properly indexed. What happens if we get to the point where tens or hundreds of thousands of users are following Sally and she's making a few dozen posts per day? You'll generate a few dozen ...


4

According to this description, NPath complexity is exponential in cyclomatic complexity. Taking just simple if statements, if you have two of these statements, that's essentially 4 routes through your code corresponding to the four possible combinations of true/false for the two statement conditions. Add another if statement and you get 8. In other words, ...


3

This rule and consequent warning is sensible - I definitely wouldn't like to see class/constant definitions mixed with side-effects in one file. But in this particular case I wouldn't mind - PHP bootstrap files are usually a bit like this - setting up the environment which sometimes consists of several distinct (and possibly unrelated) steps. You could ...


1

First, be aware that no software can ever be 100% protected from reverse engineering and decompilation, and sites such as the one you mention just illustrate this. They also illustrate that recreating code is hard to do because they tend not to work that well on applications as a whole if using all protection options that systems tend to provide, but ...


1

Can you tell me the value of using PHP encoder (ioncube, phpshield) with currently present service like decry.pt (http://www.decry.pt/) that can easily decode source codes. The value is that the source code is no longer readable by humans. I have tried decry.pt's free demo. Just drag & drop an encoded source and it will return the decoded one. ...


1

First 3 options break Liskov's substitution principle. Fourth one complicates the interface for the client. Personally I think the easiest solution would be to declare the getAmount() method that it returns always string - then it works with both integer-based and GMP-based implementations. Alternatively this might be a case of premature optimization - ...


1

It sounds very much like Paypal payments are processed. Paypal allows for sandbox accounts purely for testing purposes. Here is the link to Paypal testing guide I heard good things about it from my friends.


1

If you want to preserve data across the pages, there are several approaches: The URI or the form. A wrong choice in most situations (some ASP.NET developers would disagree, pointing to view state as an example of preserving information in a form). Sessions. This works well for most cases if the size of the preserved data is not very large. Database ...


1

The answer to this question "are mocks in unit tests dangerous in dynamic languages?" is "Hell yes!" The following article explains the dangers. They describe a scenario where an interfaces method name changed. For example, changing a methods name from error() to errors(). If we are mocking the error() method in our tests, they will never turn red to alert ...


1

Before I start I will add come context to question to highlight the problem. Consider: class SUT { public function tested(MyInterface $x) { $this->hidden($x->myMethod()); } protected function hidden($x) { $x->aMethodOfSomeObject() } } //Somewhere in test: $sutInstance($myInterfaceMock); Now. Your MyInterface::MyMethod returns ...


1

You don't have to test for the correct return type in a dynamically-typed language, unless the method is specifically designed to return a specific type (i.e. a Factory). Rely instead on other kinds of tests that are more meaningful from a program logic perspective. To give a simple (and admittedly contrived) example, if I expected a method to return a ...



Only top voted, non community-wiki answers of a minimum length are eligible