1. Time is everything
2. Brand, brand, brand
3. Put to scale your sales
4. Invest in technology
5. Stress for success
6. Hire the right people
7. Focus on your sources of real income
10. Focus on your client’s experience
11. Invest in yourself
12. Always think about the future

## Are “I’m writing android applications” and “follow open-closed principles” reasons to allow global state?

For example, suppose I have an android application, in simple, there are 3 activities :

MainActivity -> Main2Activity -> Main3Activity 

,which user can visit them in sequence (eg: by button click), also there is some global data to show:

public class GlobalData{     public static String userId; }  public class MainActivity extends AppCompatActivity {     //button click listener     public void toMain2Activity(View view){         Intent i = new Intent(this, Main2Activity.class);         this.startActivity(i);     } }  public class Main2Activity extends AppCompatActivity {     //button click listener     public void toMain3Activity(View view){         Intent i = new Intent(this,Main3Activity.class);         this.startActivity(i);     } }  public class Main3Activity extends AppCompatActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main3);     } } 

One day, Main3Activity needs to display userId in GlobalData, so I modify Main3Activity:

public class Main3Activity extends AppCompatActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main3);          Toast.makeText(this,GlobalData.userId, Toast.LENGTH_LONG).show();     } } 

But according to Why is Global State so Evil?, I should avoid global state, so I try to pass the original data object instead of allowing global state, so I try to pass the global object to Main3Activity instead of share it everywhere:

public class GlobalData implements Serializable {     public String userId="user_67890"; }  public class MainActivity extends AppCompatActivity {     private GlobalData globalData=new GlobalData();      public void toMain2Activity(View view){         Intent i = new Intent(this, Main2Activity.class);         i.putExtra("global",this.globalData);         this.startActivity(i);     } }  public class Main2Activity extends AppCompatActivity {     private GlobalData globalData;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main2);          this.globalData=(GlobalData)this.getIntent().getSerializableExtra("global");     }      public void toMain3Activity(View view){         Intent i = new Intent(this, Main3Activity.class);         i.putExtra("global",this.globalData);         this.startActivity(i);     } }  public class Main3Activity extends AppCompatActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main3);         GlobalData globalData=(GlobalData) this.getIntent().getSerializableExtra("global");         Toast.makeText(this,globalData.userId, Toast.LENGTH_LONG).show();     } } 

But I think avoiding global state is less maintainable and more unpredictable in my case because:

1. With global state, I don’t need to modify Main2Activity, which seems more fit the open closed principle, but if I want to avoid global state, I need to modify all intermediate (eg:Main2Activity) UI from start(source of GlobalData) to terminal (UI that uses GlobalData), which my android application is usually one UI component is included by another UI in depth.

2. If I pass the GlobalData only when I need it, it means I may have many functions need to add something like “GlobalData globaldata=this.getIntent().getSerializableExtra…” and “Intent i=…” everywhere, which I think it is less readable

3. In the modified version, it is possible that the this.getIntent().getSerializableExtra is failed because I may forget to put the object into the intent, and I need to handle if I get GlobalData failed, which I think it is less maintainable

4. Usually the GlobalData is not involved in Unit Test because the GlobalData is usually displayed directly, so I think sharing GlobalData doesn’t make the app harder to test

5. Using intent let me need to think how to write additional codes to pass data between same level UI components (eg:same Activity, from EditText to error message detail label)

As above, I think avoid global state is more evil than having global state in my case. So my question is, are “I’m writing android applications” and “follow open-closed principles” reasons to allow global state?

## General question about REST principles

I am unsure, if I understand the principles of REST completely.

The idea behind it is (according to e.g. Wiki and other sources) that data is transferred via HTTP(S) and addressed via URIs. Depending on the HTTP method used different operations on the underlying database are performed (CRUD operations). The glory details about different representations etc I neglect here for good reason.

This is clearly only a very minimalistic description of a REST API but as far as I see it here, it only represents a transparent “proxy” to access the (SQL) database using basic HTTP actions. So it provides the database access via API. Nothing more.

Is all business logic located on the client? Then I do not see the benefit of using such an architectural structure compared to other paradigms.

To understand things a bit more in detail, I want to describe a bit my idea and what I think might be a way to get it working:

I have a set of users A through D. Each user represents its own client. USers A through C now create some data and put this data in the database. This can be simply represented using the above mentioned structure, I agree.

Now after this is finished, user D comes into action. He has a set of rules (call them laws) and can make a series of decisions based on the data from A-C. All these desicions have to be documented in the database and influence the following options (according to the rulesets).

Now, I can make the following:

• Send the complete data from users A-C to user D and let the client’s app handle all the business logic and send the result to the server back. So after each decision the client sends the intermediate result to the server.
• Keep the business logic on the server. The user D gets only a condensed version of the data of A-C. He makes a decision and transfers it to the server. The server applies the rules and provides the options to the user D on request.

I think the first approach is critical as the user might change the business logic and send invalid data to the database through the CRUD interface. The server will not be able to detect this and accept the raw data.

On another quesion of SE (https://softwareengineering.stackexchange.com/a/323343/58867) it is suggested that the business logic is written on the server and to reduce overhead partly on the client. This last part is the part that contradicts my understanding of REST (see above).

• How is it possible to add more layers to abstract a problem using REST?
• How can one model a series of operations (one decision must be made before the next can be addressed) without transferring the whole database on each step (stateless operation)?
• The server is never stateless as he has access to the data. How is this compatible with the requirement of a stateless server?

## Principles of Adding New Objects in Backend/Database and How Front End Business Logic Should Work with Response

Apologies for the title, perhaps someone can suggest a better way to summarize my question.

Let’s say I have a task/checklist application. On the front-end, I create a task. The eventual result is that the task exists in both the front-end and the database. I have these 2 approaches:

1. I create a task in the front end by first sending a request to the backend, then awaiting for the request result. If the result is 200, then I go ahead and create the task in the front end. Now I have both the task in the front end (displayed to the user) and in the backend (saved).
2. I create a task in the front end by first sending a request to the backed, then awaiting for the request result. The request then send back not only the status code, but the entire task object itself to the front end. I take the task object (deserialized) and display it to the user.

The considerations between the 2 are:

1. With 2 I don’t need to update the logic of creating the task in 2 locations (in the front-end to create and display and in the back-end to create and store) and there could be inconsistencies between what the user sees and what is stored if incorrectly created/updated.
2. With 1 I have less network traffic. All the request needs to respond with is 200 and not the entire task object.

## What does “$E$ is not bounded above” mean? I am confused. “Principles of Mathematical Analysis” by Walter Rudin Theorem 3.17.

I am reading Walter Rudin’s “Principles of Mathematical Analysis”.

There are the following definition and theorem and its proof in this book.

Definition 3.16:

Let $$\{ s_n \}$$ be a sequence of real numbers. Let $$E$$ be the set of numbers $$x$$ (in the extended real number system) such that $$s_{n_k} \rightarrow x$$ for some subsequence $$\{s_{n_k}\}$$. This set $$E$$ contains all subsequential limits, plus possibly the numbers $$+\infty$$, $$-\infty$$.

Put $$s^* = \sup E,$$ $$s_* = \inf E.$$

Theorem 3.17:

Let $$\{s_n \}$$ be a sequence of real numbers. Let $$E$$ and $$s^*$$ have the same meaning as in Definition 3.16. Then $$s^*$$ has the following two properties:

(a) $$s^* \in E$$.

(b) If $$x> s^*$$, there is an integer $$N$$ such that $$n \geq N$$ implies $$s_n < x$$.

Moreover, $$s^*$$ is the only number with the properties (a) and (b).

Of course, an analogous result is true for $$s_*$$.

Proof:

(a)
if $$s^* = +\infty$$, then $$E$$ is not bounded above; hence $$\{s_n\}$$ is not bounded above, and there is a subsequence $$\{s_{n_k}\}$$ such that $$s_{n_k} \to +\infty$$.

If $$s^*$$ is real, then $$E$$ is bounded above, and at least one subsequential limit exists, so that (a) follows from Theorems 3.7 and 2.28.

If $$s^* = -\infty$$, then $$E$$ contains only one element, namely $$-\infty$$, and there is no subsequential limit. Hence, for any real $$M$$, $$s_n > M$$ for at most a finite number of values of $$n$$, so that $$s_n \to -\infty$$.

This establishes (a) in all cases.

I cannot understand the following argument:

(a)
if $$s^* = +\infty$$, then $$E$$ is not bounded above; hence $$\{s_n\}$$ is not bounded above, and there is a subsequence $$\{s_{n_k}\}$$ such that $$s_{n_k} \to +\infty$$.

What does “$$E$$ is not bounded above” mean?
p.12, Rudin wrote “It is then clear that $$+\infty$$ is an upper bound of every subset of the extended real number system”.
And $$E$$ is a subset of the extended real number system.

## Repository Pattern and SOLID principles

I have the following Repository wrote in C#, I am using NetCore 2.2 and EF Core.

I was thinking how to write properly the Search method according to the SOLID principles.

This code gives a null reference exception when “Title” or “Genre” property is null. It means I will need to put an if to check for null values, and in that case, it does not respect the single responsibility principle: as this method is returning a set of elements from the DB and also making some operations with strings.

How can I refactor this to avoid null exception and respect the SRP?

public class MovieRepository: IMovieRepository {     private readonly MovieDbContext _moviesDbContext;     public MovieRepository(MovieDbContext moviesDbContext)     {         _moviesDbContext = moviesDbContext;     }      public IEnumerable<Movie> GetAll()     {         return _moviesDbContext.Movies;     }      public IEnumerable<Movie> Search(MovieFilters filters)     {         var title = filters.Title.ToLower();         var genre = filters.Genre.ToLower();         return _moviesDbContext.Movies.Where(               p => (p.Title.Trim().ToLower().Contains(title) | string.IsNullOrWhiteSpace(p.Title))              & (p.Genre.Trim().ToLower().Contains(genre) | string.IsNullOrWhiteSpace(p.Genre))              & (p.YearOfRelease == filters.YearOfRelease | filters.YearOfRelease == null)            );     } } 

And this is the code that works in case of null values but I don’t know how to refactor this according to with SOLID, I will appreciate some ideas to move those IFs sentences:

public IEnumerable<Movie> Search(MovieFilters filters) {     string title = "";     if (string.IsNullOrWhiteSpace(filters.Title) == false)     {         title = filters.Title.ToLower();     }      string genre = "";     if (string.IsNullOrWhiteSpace(filters.Genre) == false)     {         genre = filters.Genre.ToLower();     }      return _moviesDbContext.Movies.Where( p => (p.Title.Trim().ToLower().Contains(title) | string.IsNullOrWhiteSpace(p.Title))                                                & (p.Genre.Trim().ToLower().Contains(genre) | string.IsNullOrWhiteSpace(p.Genre))                                                & (p.YearOfRelease == filters.YearOfRelease | filters.YearOfRelease == null)                                         ); } 

Thanks

## Using solid principles php7

I’m using this code below, but I have to implement solid principles,

<?php      abstract class HouseDetail {      private $isBroken; public function __construct(bool$  isBroken)     {         $this->isBroken =$  isBroken;     }      public function isBroken(): bool     {         return $this->isBroken; } } class Door extends HouseDetail { } class window extends HouseDetail { } class House { /** * @var HouseDetail[] */ private$  details;      /**      * @param HouseDetail[] $details */ public function __construct(array$  details)     {         $this->details =$  details;     }      public function isBroken(): bool     {         foreach ($this->details as$  detail) {              if ($detail->isBroken()) { return true; } } return false; } public function isPaintingDamaged(): bool { // MAKE AN IMPLEMENTATION } }  how can I improve the quality of this code and change anything to change anything in the existing code in order to make an implementation SOLID compliant, Principle of Dependency Inversion ? ant then i should$ House = new House([new Door(true), new window(false)]); // we pass a list of all details

## Dealing With Multiple Items on page from a form – Design Principles

I am creating a form I have read lot of practice but haven’t come to a conclusion can some one shed some light on this topic. I have a form and on this form I can add multiple items. For E.g Form Called Application as fields such as Name, Address and etc, when the user clicks the add button the application from the form will be group and can be view immediately.

My Problem

I need the group applications to be layout in a certain way.

One Method: Is that I have a button call “View Application” which shows a modal with the list of applications that were added by the user.

I am wondering if this method is scalable for a list of 50 application. For the user can edit that application from the same modal which pop out another modal. The first modal will be kill but if close goes back to the first modal.

Second is method above intrusive to the user.

Second Method: Is to have the user add the applications and display it in a table below where the user will have the ability to edit the added application using a modal.

The 2nd Method seems less atrocious but will create a scroll at the bottom due to the growth of the table. Then I guest the table could be paginated if you want to keep the UI looking clean.

Sorry I have no Mock Up shown but if you get the idea am trying to create then please can you discuss which you think is the better implementation.

## What are good guidelines and principles for designing and balancing superpower stunts in FATE Core?

I want to make a stronger focus on the F in FATE1 in my future campaigns, and that means I’m expecting said campaigns to involve what I usually see broadly referred to as special or superhuman abilities: magical spells, psionics, cyberware, superhero abilities, cinematic mutations and even mundane animal traits (the site doesn’t want me to use more than 5 tags). I have encountered different hacks for handling those, but so far, paradoxically, the approach in the Core book (p. 279-280) seemed to be the simplest and most generally applicable (and subjectively most likeable to me).

Now, the last page says ‘this is art, not science’ about the design of new stunts, but even in arts there are many do’s and do not’s.

Thus I’m asking: what are good guidelines, principles and best practices for designing and balancing superpower Stunts?

Some points refining the answers I seek:

• These don’t necessarily need to be just superhero powers. Cyberware, psionics, magic, or even some mundane animal abilities fill the niche of ‘can do what humans cannot’ too. Thus, it’s best not to be limited to any one setting or explanation of why they work.

• I’m most interested in qualitative Stunts that enable doing things that are normally not doable at all. Flight, insubstantiality, ability to Shoot without a weapon, ability to breathe water (in addition to air) indefinitely.

• Evaluating whether a stunt’s effect should be FP-powered, require a roll, or neither, and what’s a fair tradeoff for changing between these categories.

• Generally operating in a context where not all PCs and NPCs necessarily possess as many, or in fact any such powers. E.g. a Babylon 5 campaign where 1-2 PCs are telepaths and the rest aren’t; a Ghost in the Shell campaign where one PC refused to install cybernetics and thus lacks the special abilities of other PCs; a mixed Star Wars party with a Jedi/Sith, a combat droid with some odd integral modules, and a few regular folks like smugglers or diplomats. So the guidelines should produce special ability Stunts that are neither better nor worse than mundane Stunts, and no better nor worse than just hoarding Refresh.

• Already known: Being equal to one Refresh but also being more narrowly applicable, a quantitative (+2 effect) Stunt should on average get two uses per minor milestone.

• Already known: Stunts which allow using one skill instead of another in a narrow circumstance/context/etc.

• Not constructive: “Just use what works best for your table”. We are a table and we want to know the principles to estimate what would work best, and what should never be even tried etc. (In fact, a big reason for joining RPGSE for me was avoiding this sort of non-answer.)

• Outside the scope of the question: “Just use Aspect Permissions instead”; not only are Aspect Permissions worthy of a separate question, but also this answer says nothing on the topic of actually designing Stunts.

1 FATE = Fantastic Adventures in Tabletop Entertainment.

## Are there any well known alternatives to the SOLID principles for OO programming?

I´m looking for some kind of better compilation of principles which takes the old basic concepts (DRY, KISS, etc…) and applies them to OOP related concepts like abstract clasess, interfaces etc…

Some reasoning behind this quest:

I find some interpretations of the SOLID principles very compelling, but I’ve found so diverse interpretations of these principles on the web that I find them close to useless. The idea of a software design principle IMHO, is to provide a base framework for developers to discuss software development best practices. But when the advocators can’t even agree on what their principles mean, it’s time to look for alternatives.

I also have found that people trying to follow these principles create extremely over-modularized architectures mostly because they decompose simple implementations into even smaller modules, disperse over the project which makes it close to imposible to discern the purpose of these micro-modules in the context of the whole project.

Summarizing, I just want to know if there is any other well known name for a different group of OOP principles that are more tied to the old basic KISS, DRY, etc…