Skip to content

Commit

Permalink
chapter 02: removing the temporal cooupling :), who knows, maybe even…
Browse files Browse the repository at this point in the history
… it is not longer necesary the existence of genericEnconder, instead we could use the encodeFactory whenever we need it :)
  • Loading branch information
devcorpio committed Mar 30, 2019
1 parent dc74dde commit dee4183
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ function genericEncoder(encoderFactory) {
function encodeToFormat(data, format) {
const encoder = encoderFactory.createForFormat(format);

data = encoderFactory.prepareData(data);

return encoder.encode(data);
}

Expand Down
5 changes: 3 additions & 2 deletions chapter-02-the-open-closed-principle/refactor/jsonEncoder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function jsonEncoder() {
function encode() {
function encode(data) {
data = prepareData(data);

// something here...
}

Expand All @@ -14,7 +16,6 @@ function jsonEncoder() {

return {
encode,
prepareData,
};
}

Expand Down
3 changes: 2 additions & 1 deletion chapter-02-the-open-closed-principle/refactor/xmlEncoder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function xmlEncoder() {
function encode() {
data = prepareData(data);

// something here...
}

Expand All @@ -13,7 +15,6 @@ function xmlEncoder() {

return {
encode,
prepareData,
};
}

Expand Down
5 changes: 3 additions & 2 deletions chapter-02-the-open-closed-principle/refactor/yamlEncoder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function yamlEncoder() {
function encode() {
function encode(data) {
data = prepareData(data);

// something here...
}

Expand All @@ -9,7 +11,6 @@ function yamlEncoder() {

return {
encode,
prepareData,
};
}

Expand Down

0 comments on commit dee4183

Please sign in to comment.