1.1.0 • Published 2 years ago

@axa-ch/alt-pod-havarie v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Pod havarie

Migration of old Frontend lib to its own pod.

This is a pure migration from my side 😇!

Main issues in design

  • Incorrect use of redux. One connection for the whole application instead of multiple sub-store connects. It will trigger a react props comparison on every store change!
  • Overengineering: Redux totally not needed for such a small application
  • Logic very complex and abstract. To understand what something is meant to do you have to debug every line of code
  • Unnecessary API requests for getting the json. Is a hard coupled and bidirectional coupling between frontend and server as the server needs frontend and frontend needs sever in order to get countries data, which are static.
  • jQuery only used for DOM selection, not needed at all.
  • Superagent and superagentpromise ajax/fetch wrapper absolutly not needed.
  • Styling in completely different location

Refcatoring done so far:

  • Json loaded on buildtime and incoroporated as a bundle
  • From Frontendlib to POD architecture
  • PLIB v1 to PLIB v2
  • Correct usage of connect and redux
  • Add more debugging tools to the store
  • Externalise store
  • Styling per component
  • Get rid of jQuery
  • Get rid of superagent and superagentpromise
  • Self contained components (action, reducer and component in one place)

Keeping as technical depth:

  • Redux
  • Own implemented translating system
  • Helpers file
  • Semantic incorrect elements (<a> instead of <button> as example)
  • Hard coupling of the setAgents action between <HavarieFilter> and <HavarieList>
  • Agent component has no own data or store. <HavarieList> keeps state of <HavarieAgent> such as areDetailsVisible. -> Fixed

Other refactorings: From WTF code to normal code

WTF:

const dummy = Array.apply(null, { length: Math.max(comTypes.length, communications.length) })

return dummy.map((item, index) => {
  const comType = comTypes[index]

  return {
    type: comTypeMap[comType] || comType,
    communication: communications[index],
  }
})

Normalised:

  const dummy = [];

  for (let i = 0; i < Math.max(comTypes.length, communications.length); i++) {
    const comType = comTypes[i];

    dummy.push({
      type: comTypeMap[comType] || comType,
      communication: communications[i],
    });
  }

  return dummy;

how to release

1) update package.json in the "version": "1.0.0" field. Please follow semver best practices 2) run npm run release 3) commit to develop, add git tag containg the same version as in step 1 and push 4) Execute jenkins job promote with the version added in point 1