ordercloud-api / ngx-shopper

Open-source B2B e-commerce. Built with the OrderCloud.io API and maintained by the OrderCloud team
MIT License
9 stars 22 forks source link

Naming Conventions for Component Outputs #126

Open robertsoniv opened 6 years ago

robertsoniv commented 6 years ago

While looking over some of the code I noticed some odd naming conventions for the component outputs on the LineItemCard: https://github.com/ordercloud-api/ngx-shopper/blob/881aafb5cd2dfb93223b8470ab8726b720527818/src/UI/Buyer/src/app/shared/components/line-item-card/line-item-card.component.ts#L16-L17

I'm sure there are a few more sprinkled about.

Since outputs will often be used when you may not have the component's source readily available I think it's important they are named predictably. Would this issue's conversation be a good place to discuss possible naming conventions? Here's my two cents:

onUpdate
onDelete
onSave
on*Whatever*

Obviously, you'd have to be careful and avoid using native browser attribute handlers, like onClick.

oliverheywood451 commented 6 years ago

I like this suggestion a lot.

crhistianramirez commented 6 years ago

I actually had looked into this previously. Its in the angular style guide specifically to not use "on" prefix. One of the reasons is one you actually brought up (because there's already native browser attribute handlers)

https://angular.io/guide/styleguide#dont-prefix-output-properties

We could deviate from the style guide but i think its really nice to just have a well-documented style guide we can point people to.

crhistianramirez commented 6 years ago

We should probably add, that we follow the angular style guide to the readme 🤔