Skip to content

Instantly share code, notes, and snippets.

@zahra-ove
Last active April 8, 2022 09:44
Show Gist options
  • Save zahra-ove/a082d46e0855361027fcfaba80434ebb to your computer and use it in GitHub Desktop.
Save zahra-ove/a082d46e0855361027fcfaba80434ebb to your computer and use it in GitHub Desktop.

note1: form-data vs x-www-form-urlencoded

These are different Form content types defined by W3C. If you want to send simple text/ ASCII data, then x-www-form-urlencoded will work. This is the default. But if you have to send non-ASCII text or large binary data, the form-data is for that. link

note2: What is a Service?

Service is a very loaded term in computer programming that has all sorts of different meanings and connotations depending on the context you are using it in.

A Service in Domain Driven Design is simply a stateless object that performs an action.

For example, an AuthenticationService would have the sole responsibility for authenticating users into your application.

An important characteristic of a Service is that it should not have state. So the AuthenticationService should be used to perform an action such as authenticate() but it should not hold any references to stateful data such as the current authenticated users. link

note3: interface can extends multiple interfaces in php

link

note4: Is dependency injection basically just composition?

I think it’s better to say that dependency injection relies on composition, but is a method for achieving Inversion of Control

This better highlights what’s special about it - that the object doesn’t control the construction of its parts. For example if you had a BlogPost object that has a reference to a DataBase object, in composition it would be perfectly OK to construct that DataBase instance yourself, in your BlogPost constructor - but this is a no-no in dependency injection; you’re supposed to get the DataBase instance from the outside (as a parameter or something).

Why is this important? In general this helps you decouple your code, but in particular it is useful for e.g. unit tests - to continue the above example, the unit test could pass in a mock database object, so that without changing a single line of code all database calls can now be intercepted and redirected to memory or something (and test data can be supplied, again without ever touching a network connection, which could make your test fail for reasons that have nothing to do with your code, like somebody tripping over the cable). link

note5:

there is 3 different concept in programming:

  • association
  • aggregation
  • composition this link may help better to understand.

note6:

is-a ==> inheritance has-a ==> association

association has two types: - aggregation - composition

aggregation: weak association composition: strong association




important links

Learning PHP: link

Decorator Pattern: Link Design patterns: link

DDD: link1 link2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment