This is an interesting week for me! It marks the end of my time at Flexiti as I have decided to take some time to explore some fun ideas and projects that I’ve had on the backburner for a while. I’m sure many can relate and agree with the pandemic bringing along thoughts and feelings of: what is truly important in life and where do I want take myself going forward? It is definitely a good time to take action on those things we’ve held ourselves back from pursuing because time is precious. Life is precious. Joy and satisfaction are important. The company has a great team of architects now that will help them with the tremendous growth ahead of them. When I began there, I was the only Architect and since then eight more have been hired. It has been a pleasure to be a part of that expansion. I learned a lot during my time at Flexiti and accomplished some great work that I’m proud of. I created and chaired the Architecture Review Board. Wrote the API documentation standards, an API governance document and an API workflow document. Wrote the Branch Strategy document and created presentations such as the business case for moving to Micro-services. Created a Technology Radar for Flexiti and ran numerous sessions. Updated or wrote dozens of Architecture diagrams and documents including six High Level Estimates and High Level Design Documents in the last few months. As lead architect of our digital transformation project I was able to help Flexiti to begin their MuleSoft journey. It is always a little scary to resign from a great job at a great company but it’s important to listen to one’s instincts and follow the path of personal growth and development. I wish my friends at Flexiti the best of luck!
0 Comments
I've been working in the corporate IT industry for many years. Some things have changed and some things haven't. The workplace now includes millennials, boomers, different genders and nationalities from around the world as globalization continues. The compassion, empathy and understanding between cultures has been growing but we are only on the cusp of that change. I'm not the only one that dreams of a world envisioned by Gene Rodeneberry on the bridge of the starship enterprise in Star Trek so many years ago, a world where all cultures are accepted without question. I have asked my employers to let me post this over the last few years with the simple preface, "This is important to me".
"A few years ago, my daughter told me she was lesbian. The first thing I did was find out as much as I could about this and I discovered the pride parade. This is an opportunity for the LGBTQ community to be able to be proud of who they are; unashamed and unafraid. Hopefully, one day, we live in a society where an annual parade is no longer needed but for now I believe we need to show solidarity with the LGBTQ community." I am grateful they have allowed me. Let's all do our part to push this agenda forward and hope our children (or grandchildren) don't have to think about this in the future. I recently had a business problem which required using the "using" operator in Data Weave. I noticed there wasn't a lot of documentation on it so this will be a brief overview of my problem and how the using operator helped me. {"letterCountArray": [ {"letter": "A","count": 5}, {"letter": "B","count": 3}, {"letter": "C","count": 6}, {"letter": "D","count": 5}, {"letter": "E","count": 7}]} Our requirement is to display the letter and count for A, B and C. result: payload.letterCountArray filter $.letter == "A" or $.letter == "B" or $.letter == "C" map { (letterA: { Letter: $.letter, Count: $.count }) when $.letter == "A", (letterB: { Letter: $.letter, Count: $.count }) when $.letter == "B", (letterC: { Letter: $.letter, Count: $.count }) when $.letter == "C" } which will give the result { "result": [ { "letterA": { "Letter": "A", "Count": 5 } }, { "letterB": { "Letter": "B", "Count": 3 } }, { "letterC": { "Letter": "C", "Count": 6 } } ] } Now the user says, I love your program but... I would like to have the sum of E and D counts. A simple solution is to use the using operator. You can create a function to sum the count of D and E and put that into a variable. You can use that variable to display the count within the map. %function getCountDandE(letterCountArray) ( letterCountArray filter $.letter == "D" or $.letter == "E" map { count: $.count}.count reduce ($$ + $) ) --- result: payload.letterCountArrayfilter $.letter == "A" or $.letter == "B" or $.letter == "C" or $.letter == "D" map using (countOfDandE = getCountDandE(payload.letterCountArray)){ (letterA: { Letter: $.letter, Count: $.count }) when $.letter == "A", (letterB: { Letter: $.letter, Count: $.count }) when $.letter == "B", (letterC: { Letter: $.letter, Count: $.count }) when $.letter == "C", (letterDandE: { Letter: "D+E", Count: countOfDandE }) when $.letter == "D" } which will now give the result: { "result": [ { "letterA": { "Letter": "A", "Count": 5 } }, { "letterB": { "Letter": "B", "Count": 3 } }, { "letterC": { "Letter": "C", "Count": 6 } }, { "letterDandE": { "Letter": "D+E", "Count": 12 } } ] } As you can see the using operator is a powerful feature but remember, as Stan Lee says, "with great power comes great responsibility". Reduce allows us to iterate an array to accumulate a result. There are a few array operators like filter and map that do similar functions. You can use reduce to filter an array or map an array because you can reduce an array into another array but that wouldn't be best practice. Ideally you want to use reduce to produce a single result. %dw 2.0 output application/json --- { "sum reduce short form" : [0, 1, 2, 3, 4, 5] reduce ($$ + $), "sum long form" : [0, 1, 2, 3, 4, 5] reduce ((val, acc) -> acc + val), "sum sum operator" : sum ([0, 1, 2, 3, 4, 5]), "sum start" : [0, 1, 2, 3, 4, 5] reduce ((val, acc=2) -> acc + val), "sum sum operator with start value" : 2 + sum ([0, 1, 2, 3, 4, 5]) } Which will produce these results: { "sum reduce short form": 15, "sum long form": 15, "sum sum operator": 15, "sum start": 17, "sum sum operator with start value": 17 } If you have a shop with many DataWeave developers (more than three) I'd go with the short form of reduce otherwise the long form is more intuitive to a non DataWeave developer trying to maintain the code. %dw 2.0 output application/json var sentence ="How are you doing?" --- { "string created with reduce": ["H", "e", "l", "l", "o"] reduce($$ ++ $), "string created with joinBy": ["H", "e", "l", "l", "o"] joinBy(""), "words created with splitBy" : sentence splitBy(" "), "sentence processed with splitBy filter and reduce" : (sentence splitBy(" ")) filter $ != "are" reduce($$ ++ " " ++ $), "sentence processed with splitBy filter and joinBy" : (sentence splitBy(" ")) filter $ != "are" joinBy(" ") } which produces the following results: { "string created with reduce": "Hello", "string created with joinBy": "Hello", "words created with splitBy": [ "How", "are", "you", "doing?" ], "sentence processed with splitBy filter and reduce": "How you doing?", "sentence processed with splitBy filter and joinBy": "How you doing?" } Reduce can be useful when you need to apply a function to every item in the array, for example, applying a tax rate with rounding to each value, to ensure you get the correct rounding for your total result. I'll be writing an article about the more advanced uses of reduce shortly. |