Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phone book #23

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Phone book #23

wants to merge 10 commits into from

Conversation

maxeasy18
Copy link
Collaborator

Основные функции работают.
Из того что я знаю точно не работает:

  • не форматируется номер при правке во время правки пользозвателя.
  • не меняется заголовок страниці у режима правки пользователя (стоит заголовок от добавления пользователя).
  • не сделан переход добавления клиента из кейпада.

Вобще получилось очень сумбурно и я уверен что архитектур у к черту неправильная, но как его все связать правильно я не знаю...
MVC скорее всего тоже не получится.


<script src="src/users.js"></script>
<script src="src/router.js"></script>
<script src="src/server-api.js"></script>
<!-- <script src="src/contacts.js"></script> -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's seems like an a duplication with line 20, please remove it

<script src="src/keypad.js"></script>
<script src="src/edit-user.js"></script>
<script src="src/user.js"></script>
<!-- <script src="src/add-user.js"></script> -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what the status of that script? it's better to remove commented code. The commented code just makes discouraged the next developer who inspect such code

const fs = require('fs');
const port = 3000;

http.createServer( (request, response) =>{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally, you need your own server only for development purpose, so you could use some instruments like webpack-dev-server or so

class App {
constructor(appContainerId) {
this.state = {};
this.appContainer = document.getElementById(appContainerId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appContainerId - not sure that variable should be dynamic, it's fine to make it static


renderAppContainer(){
return `
${this.renderAppHead()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's safe to store all HTML content inside the current method, no need additional abstraction.

I've been talked about additional methods when we've been used document.createElement in such situation abstraction could tell us more. But if you have just a plain HTML, no need an additional abstraction

const serverAPI = this.app.serverAPI;
const updatingUser = serverAPI.updateUser(data);
updatingUser.then( response => {
this.app.pages.contacts.pageObject.users = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's breaking single responsibility principal an could causes unpredictable errors in future

const serverAPI = this.app.serverAPI;
const addingUser = serverAPI.addUser(data);
addingUser.then( response => {
return response.json();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

return response.json();
})
.then(addedUser => {
this.app.pages.contacts.pageObject.users = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's breaking single responsibility principal an could causes unpredictable errors in future

const serverAPI = this.app.serverAPI;
const deletingUser = serverAPI.deleteUser(id);
deletingUser.then( response => {
this.app.pages.contacts.pageObject.users = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like really mess.

I believed pageObject is required overhead to structure, but it just makes the code more confusing.
If you want to store something you have to move its state and work with it directly.

If you want to update state - make 1 method where all updates would happens.

You could desing your app state withholding in mind 1 idea "I need to log my new state in console every time something changing"

const newPage = 'contacts';
const newState = { activePage : newPage };
this.app.updateState(newState);
this.app.router.gotToPage(this.app.state);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well as I see it's not bad at all, but with problem in architecture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants