Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

First off, let me say this: There's no need for your bootstrap to be OO. Your Bootstrap class will become a utility class with no real purpose, which does everything. That is also known as a God Object .

From what I see, you're better off using the procedural one.


Review for OO:

  • Naming convention: Setters should be prefixed with set: setDirectorySeparator, setRootPath, etc. It's not clear what directorySeparator does at a glance.
  • Don't use Globals: The entire point of moving an application to OOP is to better manage the dependencies and move away from global variables.
  • Don't use Service Locators: Your $config variable is a service locator. You will inject it (or worse, global include it) everywhere, it contains all of the configurations and all you need is one or two entries. Don't do that. Give each function/method exactly what it needs.
  • Application bootstrapping should not be OO. See above explanation.

Review for Procedural

  • Use a class for Autoloading: It makes things a whole lot simpler, and it looks nicer too. I see you're using PSR-0, there are easy and simple solutions out there available.
  • Arbitrarily requiring files and adding ini entries is not safe: If you don't sanitize user input properly in any part of your application, this may cause you some severe breakage on the server. Beware!

Here's an example for a good bootstrap file for an MVC application: How should a Model be structured in MVC? How should a Model be structured in MVC?

First off, let me say this: There's no need for your bootstrap to be OO. Your Bootstrap class will become a utility class with no real purpose, which does everything. That is also known as a God Object .

From what I see, you're better off using the procedural one.


Review for OO:

  • Naming convention: Setters should be prefixed with set: setDirectorySeparator, setRootPath, etc. It's not clear what directorySeparator does at a glance.
  • Don't use Globals: The entire point of moving an application to OOP is to better manage the dependencies and move away from global variables.
  • Don't use Service Locators: Your $config variable is a service locator. You will inject it (or worse, global include it) everywhere, it contains all of the configurations and all you need is one or two entries. Don't do that. Give each function/method exactly what it needs.
  • Application bootstrapping should not be OO. See above explanation.

Review for Procedural

  • Use a class for Autoloading: It makes things a whole lot simpler, and it looks nicer too. I see you're using PSR-0, there are easy and simple solutions out there available.
  • Arbitrarily requiring files and adding ini entries is not safe: If you don't sanitize user input properly in any part of your application, this may cause you some severe breakage on the server. Beware!

Here's an example for a good bootstrap file for an MVC application: How should a Model be structured in MVC?

First off, let me say this: There's no need for your bootstrap to be OO. Your Bootstrap class will become a utility class with no real purpose, which does everything. That is also known as a God Object .

From what I see, you're better off using the procedural one.


Review for OO:

  • Naming convention: Setters should be prefixed with set: setDirectorySeparator, setRootPath, etc. It's not clear what directorySeparator does at a glance.
  • Don't use Globals: The entire point of moving an application to OOP is to better manage the dependencies and move away from global variables.
  • Don't use Service Locators: Your $config variable is a service locator. You will inject it (or worse, global include it) everywhere, it contains all of the configurations and all you need is one or two entries. Don't do that. Give each function/method exactly what it needs.
  • Application bootstrapping should not be OO. See above explanation.

Review for Procedural

  • Use a class for Autoloading: It makes things a whole lot simpler, and it looks nicer too. I see you're using PSR-0, there are easy and simple solutions out there available.
  • Arbitrarily requiring files and adding ini entries is not safe: If you don't sanitize user input properly in any part of your application, this may cause you some severe breakage on the server. Beware!

Here's an example for a good bootstrap file for an MVC application: How should a Model be structured in MVC?

Bounty Awarded with 50 reputation awarded by Kid Diamond
Source Link
Madara's Ghost
  • 4.8k
  • 25
  • 46

First off, let me say this: There's no need for your bootstrap to be OO. Your Bootstrap class will become a utility class with no real purpose, which does everything. That is also known as a God Object .

From what I see, you're better off using the procedural one.


Review for OO:

  • Naming convention: Setters should be prefixed with set: setDirectorySeparator, setRootPath, etc. It's not clear what directorySeparator does at a glance.
  • Don't use Globals: The entire point of moving an application to OOP is to better manage the dependencies and move away from global variables.
  • Don't use Service Locators: Your $config variable is a service locator. You will inject it (or worse, global include it) everywhere, it contains all of the configurations and all you need is one or two entries. Don't do that. Give each function/method exactly what it needs.
  • Application bootstrapping should not be OO. See above explanation.

Review for Procedural

  • Use a class for Autoloading: It makes things a whole lot simpler, and it looks nicer too. I see you're using PSR-0, there are easy and simple solutions out there available.
  • Arbitrarily requiring files and adding ini entries is not safe: If you don't sanitize user input properly in any part of your application, this may cause you some severe breakage on the server. Beware!

Here's an example for a good bootstrap file for an MVC application: How should a Model be structured in MVC?

lang-php

AltStyle によって変換されたページ (->オリジナル) /