Title: Code quality
Last modified: January 24, 2017

---

# Code quality

 *  [gidomanders](https://wordpress.org/support/users/gidomanders/)
 * (@gidomanders)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/code-quality-4/)
 * **My story**
    I am a developer myself and I love working with WooCommerce. I 
   think it’s a great plugin with many many possibilities, though very simple to
   use.
 * For a client, I have to convert/import an old database of products into WooCommerce.
   I used a lot of functions in the WooCommerce API for this, so my code was pretty
   clean and short.
 * After the client walked through the products and changed some things, they found
   out an attribute and some variations were incorrect. Now I have to loop through
   the variations to update them without overwriting their changes.
 * **My problem**
    I found out that the API is not able to help met update one variation
   or only an attribute for that variation. So I searched for the code that saves
   variations when you change it manually in wp-admin. That’s when I found out that
   a lot of the code in the API is literally a copy of the code used by wp-admin.
   Also the functions are about 230 lines of code.
 * **My question(s)**
    Separating functionalities into functions that do only one
   thing, or in coding terms the single responsibility principle. Very useful in
   big projects like WooCommerce. It allows for code to be re-used and makes your
   code much more readable. I found parts of the save_variations() functions, like
   updating attributes, to be very useful in my case, but I cannot use the WooCommerce
   solution because the code is not a separate function. Why does it seem like code
   quality is not managed/guaranteed at all? Are you guys working on this?

The topic ‘Code quality’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [gidomanders](https://wordpress.org/support/users/gidomanders/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/code-quality-4/)
 * Status: not resolved