Monthly Archiv: February, 2021

Successful refactoring projects – Prepare to stop at any time

Refactoring projects

A common case of refactoring-gone-wrong is when refactoring becomes a large project in a branch that can never be merged because the refactoring project is never completed. The refactoring project is considered a separate project, and soon starts to feel like "The Big Rewrite That Always Fails" from programming literature.

The work happens in a branch because people actually fear the change. They want to see it before they believe it, and review every single part of it before it can be merged. This process may take months. Meanwhile, other developers keep making changes to the main branch, so merging the refactoring branch is going to be a very tedious, if not dangerous thing to do. A task that, on its own, can cause the failure of the refactoring project itself.

Short-lived branches

So can't we use a branch for refactoring? Of course we can. But it has to be a short-lived branch. How can you ensure that a branch is short-lived?

  1. It has small commits, created within small time intervals (e.g. minutes, not hours)
  2. Each commit passes all the tests (meaning the actual tests pass, and static analysis yields no errors)
  3. The branch can be merged and deployed at all times (and actually, should be merged regularly)

Following this set of rules is a great idea for any branch, not just refactoring branches. But it's even more important there, since the changes are likely to span many, and remote parts of the code base, which makes the risk of merge problems bigger.

What often happens is that we change a method in a way that requires updating all its clients. It takes a lot of time to do this work, and so we end up with either a very large commit, or a commit that just takes a lot of time to make, meaning that we don't follow the first rule of short-lived branches.

Something else that could happen is that we are just viciously updating code all around the code base, and we commit the changes because everything seems alright, but then our quality assurance tools tell us something is wrong. When we get the results back from CI, we add another commit that "Fixes tests" or "Makes PHPStan happy". When working with short-lived branches, ensure that everything is okay before committing (or set up a pre-commit hook so you can't forget to do this).

What if we have to stop now?

Creating small commits that pass all the tests, the result should indeed be that our branch can be merged at all times. This for me is closely aligned to a thought I always have in mind when programming: what if someone pulls the plug on this project today? I don't want my effort to be wasted, I don't want my branch to be deleted without merging. So when I work on something I always aim for it to be useful for the team, the company, its users, etc.

One way to make sure that you always add value to the project is to establish goals for which the following is true:

  • The bigger goal can be reached in a number of smaller steps
  • Each step is useful when considered on its own

We'll take a closer look at refactoring goals in the next article.

Conclusion

Refactoring projects require short-lived branches, where every commit can be merged in the main branch immediately. You should be able to stop the refactoring project at any time, while still leaving the project in a better state.

Finding and Using Your Own Design Voice

Your design voice – or design style, if you will – is how you choose to relay information to your audience. That sounds simple, but for the uninitiated, it can be incredibly confusing.

I have a confession to make: when I started writing this article, I was stumped at how to best phrase my main idea. I had something important I needed to tell you wonderful readers, but I just wasn’t sure how to do it.

Then it hit me that I wasn’t approaching it in a writing voice I recognized as being “mine.” I was attempting to get too lofty with my idea (since it’s so important and all), and missing the point of my own message. How’s that for irony? In your face, Alanis Morissette.

I eventually decided to scrap what I was originally going to write about, and start over in my own personal style. I love telling stories, and I think that’s where I shine as a writer. Plus, I’m incredibly modest, as you can tell.

So, what is voice? What is personal style, and how can we creatives develop it? One thing’s for sure – it’s not just something for writers to think about. Creative professionals of all stripes struggle with developing their own unique way to express their ideas, especially with so many amazing people out there doing things we admire and are inspired by.

It can be hard sometimes to separate what you admire from who you are, but it’s certainly doable. The key is knowing how to interpret the feedback you get from others.

row microphones vintage blue wood

Translating The Conversation

It’s entirely possible to say one thing dozens, and sometimes even hundreds of different ways. Typography is the best way to illustrate this point. A poster that doesn’t hold back with the chunky slab serifs is going to have a completely different emotional impact than one that uses a delicate, understated script – even if the message is exactly the same.

The design language you use will be different depending on who it is you’re trying to reach. I say language quite deliberately because I compare what we do for our clients as designers to what an interpreter does for two people who speak different languages.

Interpreters create commonality and facilitate conversation between two opposite forces, much the same way that a designer facilitates a communication between their client and their client’s audience. You take what your client has to say and tell it to their audience in a way that’s clear for both parties to understand.

When you develop your own personal design voice, you are effectively alienating those people who don’t care for your style, just like a baby’s brain closes itself off to all of the potential sounds a human being can make in favor of the particular set it learns from its parents.

When you’re born, you can effectively speak every language. But the more you learn and listen, the more certain words and sounds take precedence over the others.

By the time you can talk, you’re communicating in whatever your first language is, excluding all the others you could have learned instead. It’s impossible to try to learn every single language in the world, so why should you try to earn the approval of every single person with your design work? The best way you can use your own voice is to reach people who want to hear your specific message.

The world in general wants you to be bland and inoffensive, easy to understand and digest. But your niche audience wants the compelling visual narrative that only you can give them.

the secret to creativity is knowing how to hide your sources Albert Einstein quote

When Inspiration Becomes Copying

Without a doubt, the best way you can expand your own design fluency is by learning from others. Like I said, there’s a ton of exciting, creative work out there that inspires us all, and the argument has certainly been made many times that there’s “nothing new under the sun” in terms of ideas. But there comes a time when design inspiration can go too far and veer off into plain old copyright infringement.

In 2010, copyright representatives for Dutch author Dick Bruna successfully sued Japanese heavyweight Sanrio for copyright infringement over Sanrio’s white bunny character, Cathy.

Bruna, who created the white bunny character Miffy in 1955, said explicitly that Cathy was “a copy” of his famous children’s book bunny, who was very popular in Japan several decades before Sanrio began licensing their character designs. But Sanrio’s Cathy was pretty obviously done in Sanrio’s own style – the bunny character looks very much like their iconic Hello Kitty.

bruna character illustration yellow background

Was Sanrio merely designing in their signature style, or was it in fact a deliberate infringement on Bruna’s copyright? There are plenty of incidences of simultaneous design, when more than one person comes up with the exact same or a series of very similar ideas at around the same time. But as a general rule, unless you can prove in court that you were the original holder of a copyright, it’s not really a good idea to fall victim to that kind of unknowing.

Doing your research, involving yourself in the creative community, and making sure you know who your competition is are vital steps to maintaining your reputation as an original designer with an original voice.

As Albert Einstein said, “the secret to creativity is knowing how to hide your sources.” Being inspired means not being ignorant of what your peers are doing.


Remember, your main goal as a freelancer is getting repeat customers who respond well to your unique voice. If you’re telling your own stories and drawing from your own personal experiences, it’s virtually impossible to create designs that look just like everyone else’s.

You can’t help but be original when you’re being authentic.

The post Finding and Using Your Own Design Voice appeared first on Speckyboy Design Magazine.

WordPress 5.7 Beta 3

WordPress 5.7 Beta 3 is now available for testing! 🗣

This software is still in development, so it’s not recommended to run this version on a production site. Consider setting up a test site to play with it.

You can test the WordPress 5.7 Beta 3 in two ways:

  • Install/activate the WordPress Beta Tester plugin (select the Bleeding edge channel and the Beta/RC Only stream)
  • Direct download the beta version here (zip).

The current target for final release is March 9, 2021. That’s just three weeks away, so your help is vital to making sure that the final release is as good as it can be.

Some Highlights

Since Beta 2, 27 bugs have been fixed. Here is a summary of some of the included changes:

  • Adjusted color contrast on various admin buttons to improve accessibility and readability (#52402)
  • Several fixes for the Twenty Twenty-One theme (#52287, #52377, #52431, #52500, #52502, #52412)
  • Replaced editor typeface with system fonts to improve privacy and performance (#46169)
  • Added i18n support to register_block_type_from_metadata function (#52301)
  • Media upload errors are now more accessible (#47120)
  • New filter to modify how pagination links are rendered when using paginate_links function (#44018)

How You Can Help

Watch the Make WordPress Core blog for 5.7-related developer notes in the coming weeks, which will break down these and other changes in greater detail.

So far, contributors have fixed 171 tickets in WordPress 5.7, including 64 new features and enhancements, and more bug fixes are on the way.

Do some testing!

Testing for bugs is a vital part of polishing the release during the beta stage and a great way to contribute. ✨

If you think you’ve found a bug, please post to the Alpha/Beta area in the support forums. We would love to hear from you! If you’re comfortable writing a reproducible bug report, file one on WordPress Trac. That’s also where you can find a list of known bugs.

Props to @audrasjb and @lukecarbis for your peer revisions.


Finish line ahead
Defects in focus
We are almost there…

OnTime Group

Package:
OnTime Group
Summary:
Manage user groups and their access permissions
Groups:
PHP 7, Security, User Management, Utilities and Tools
Author:
Mario Carrocera
Description:
This package can manage user groups and their access permissions...

Read more at https://www.phpclasses.org/package/11974-PHP-Manage-user-groups-and-their-access-permissions.html#2021-02-16-12:30:33

Community News: Latest PECL Releases (02.16.2021)

Latest PECL Releases:

  • ice 1.8.0alpha3
    - Pecl, add build directories fix #271

    • Di, resolve default services in cli fix #295
    • Loader, register namespaces in the constructor fix #294
  • ev 1.1.2
    Fixed Windows build configuration for PHP 8
  • ev 1.1.1r1
    Stable version release
  • event 3.0.2r1
    Stable version release.
  • gnupg 1.5.0RC1
    * Added support for PHP 8 * Added support for GnuPG 2.1+ * Added argument info for all functions and methods (reflection support) * Added new function `gnupg_getengineinfo` * Added new function `gnupg_geterrorinfo` * Added init array argument for setting home dir and gpg binary file name * Added additional fields to `gnupg_keyinfo` returned array * Added parameter to `gnupg_keyinfo` to use `secret_only` * Fixed `gnupg_deletekey` to use boolean for `allow_secret` parameter
  • Tensor 2.1.03
    No notes
  • Tensor 2.1.3
    No notes
  • ice 1.8.0alpha2
    - PHP 7.1, drop support, update phpunit to v8 - Update zephir parser to 1.3.5 - Zephir, use zephir-php8 branch - Pdo, fix associative array in order by - PHP 7.2 and 7.3, drop support - Tests, fix get related count and filter - Version, remove hyphen fix #292
  • gmagick 2.0.6RC1
    Works with PHP 8 but some fixes still required.
  • smbclient 1.0.5
    Fixes possible segfault in php_smb_ops_close.
  • protobuf 3.15.0RC1
    PHP protobuf
  • maxminddb 1.10.0
    * When using the pure PHP reader, unsigned integers up to PHP_MAX_INT will now be integers in PHP rather than strings. Previously integers greater than 2^24 on 32-bit platforms and 2^56 on 64-bit platforms would be strings due to the use of `gmp` or `bcmath` to decode them. Reported by Alejandro Celaya. GitHub #119.

Should we use a framework?

Since I've been writing a lot about decoupled application development it made sense that one of my readers asked the following question: "Why should we use a framework?" The quick answer is: because you need it. A summary of the reasons:

  • It would be too much work to replace all the work that the framework does for you with code written by yourself. Software development is too costly for this.
  • Framework maintainers have fixed many issues before you even encountered them. They have done everything to make the code secure, and when a new security issue pops up, they fix it so you can just pull the latest version of the framework.
  • By not using a framework you will be decoupled from Symfony, Laravel, etc. but you will be coupled to Your Own Framework, which is a bigger problem since you're the maintainer and it's likely that you won't actually maintain it (in my experience, this is what often happens to projects that use their own home-grown framework).

So, yes, you/we need a framework. At the same time you may want to write framework-decoupled code whenever possible.

Here's a summary of the reasons. If all of your code is coupled to the framework:

  • It will be hard to keep up with the framework's changes. When their API changes, or when their conventions or best practices change, it takes just too much time to update the code base.
  • It's hard to test any business logic without going through the front controller, that is, by making fake or real web requests to your application, analyzing the response html, or peeking into the database.
  • It's hard to test anything at all, because nothing allows itself to be tested in isolation. You always have to set up a database schema, populate it with data, or boot a service container of some kind.

Pushing for a big and strong core of decoupled code, that isn't tied to the database technology, or a particular web framework, will give you a lot of freedom, and prevents all of the above problems. How to write decoupled code? There's no need to reinvent the wheel there either. You can rely on a catalog of design patterns, like:

  • Application services and command objects
  • Entities and repository interfaces
  • Domain events and domain event subscribers

None of these classes will use framework-specific things like:

  • Request, Response, Session, Token storage, or security User classes,
  • Service locators, configuration helpers, dependency resolvers,
  • Database connections, query builders, relation mappers, or whatever your framework calls them.

For me good rules of thumb to test the "decoupledness" of my business logic are:

  1. Can I migrate this application from a web to a CLI application without touching any of the core classes?
  2. Can I instantiate all the classes in the core of my application without preparing some special context or setting up external services?
  3. Can I migrate this application from an SQL database to a document database without touching any of the core classes?

1 and 2 should be unconditionally true, 3 allows some room for coupling due to the age-old problem of mapping entities to their stored format. For instance, you can have some mapping logic in your entity (i.e. instructions for your ORM on how to save the entities). But at least there shouldn't be any service dependencies that are specific to your choice of persistence, e.g. you can't inject an EntityManagerInterface or use a QueryBuilder anywhere in your code classes. Also, calling methods should never trigger actual calls to a database, even if it's an Sqlite one.

If you do all of this, your framework will be like a layer wrapped around your decoupled core:

This layer contains all the technical stuff. This is where you find the acronyms: SQL, ORM, AMQP, HTTP, and so on. This is where we shouldn't do everything on our own. We leverage the power of many frameworks and libraries that save us from dealing with all the low-level concerns, so we can focus on business logic and user experience.

A framework should help you:

  • Make a smooth jump from an incoming HTTP request to a call to one of your controllers.
  • Load, parse, and validate application configuration.
  • Instantiate any service needed to let you do your work.
  • Translate your data to queued messages that can be consumed by external workers.
  • Parse command-line arguments and pass them as ready-to-consume primitive-type values.
  • Turn your application's data in

Truncated by Planet PHP, read more at the original (another 1854 bytes)

PHP Creative Commons Logo (New)

Package:
PHP Creative Commons Logo
Summary:
Display a logo link for a Creative Commons License
Groups:
Graphics, HTML, PHP 5, Utilities and Tools
Author:
Mario Carrocera
Description:
This class can be used to display a logo link for a Creative Commons License...

Read more at https://www.phpclasses.org/package/11975-PHP-Display-a-logo-link-for-a-Creative-Commons-License.html
Powered by Gewgley