5 mistakes to avoid when modeling your application

on August 18, 2015

Share:

Since joining the Mendix team, I’ve seen a number of common mistakes that our customers make when they are new to visual modeling. In this blog post, I’ll highlight five of these mistakes and illustrate how you can avoid similar issues in your own development efforts.

1. You are refreshing and committing everything

Often, new platform users are either over-eager or unconcerned with how often they commit and refresh objects into the database. However, it is important to refresh and commit at the right times. To understand why this is an issue, let’s look at a couple of examples.

Here is a simple example of a common mistake that users make when creating a new course object:

Microflow-new-course-entity

Image 1: Microflow that creates a new course entity and passes it to the Course_NewEdit pages

Based on the logic above, if a user hits cancel in the new course page, the person will end up with a blank course record in your datagrid. You are persisting an object to the database when you hit the new button instead of save. You should only commit when you want to save an object to the database. Think about when you need to create a new database record and if it it’s necessary to persist the object in the database.

Here is an example of not refreshing appropriately:

Microflow-non-proper

Image 2: The non-proper delete button is NOT refreshing on delete.

In this instance, when a user deletes an object, they will still see that record. This happens because you need to refresh the client to reflect the latest changes to the database. This does not mean that you need to go and over-refresh on everything. Just ask yourself, “when is it necessary to update the client and refresh objects?”

2. Your XPath constraints and retrievals are inefficient

Inefficient retrievals on Microflows or on the UI can cause performance problems. You can learn more about how to structure efficient XPath constraints in this expert services webinar, in this post focused on performance, or in this reference guide document. For an in-depth course on this subject, Mendix also provides an advanced training course which I highly recommend.

Think of XPath constraints as conditionals. From there, you are just filtering your data to display or retrieve the necessary information. Keep them simple and if you need to complicate them, use the resources above to do it right.

3. You forgot to add empty checks

Have your users seen the error below before? There are a variety of errors that may come up, but often these errors relate to empty checks (or the omission of these checks). Remember, it’s important to add empty checks whenever you reuse objects within your Microflow.

Error

For example, if you receive this error, run a quick analysis on your logs (or even the Mendix console). In this instance, the error relates to the IVK_CommitSubscription Microflow, specifically the ‘Person’ object cannot be null.

Stack Trace

As mentioned above, this often happens because you forgot to add an empty check somewhere in your Microflow logic. And if you look at the guilty Microflow, you’ll notice that we change the person object. When a user creates a new subscription, he or she might forget to select a person. In that instance, you need to add an empty check.

4. You forgot you can’t divide by zero.

Similarly to empty checks, if you are building applications where you need to add calculations, it’s always a good idea to add a check if you are dividing by 0. The user will see the same error as the empty check. However, in the logs you’ll see a ‘Failed to Evaluate’ expression error.  My coworker Adam elaborates on more common runtime errors in his blog post here.

5. Your security isn’t actually secure enough

Don’t just select all user roles for access to every page or Microflow. Take the time to select the right roles for the right purposes. For example, if you get an error message (like the one below), your instinct may be to quickly remove the problem by selecting all user roles for access to all components. However, this instinct is wrong and exposes your application to more risk.

Be wary of how you implement security and limit access to your Microflows. For more security details and best practices check out this blog post and this how to.

In conclusion, I hope you will avoid the most common mistakes when you start developing. Come and join us for our Mendix Advanced Training where you will further expand on your Mendix knowledge!

Subscribe to Our Blog

Receive Mendix platform tips, tricks, and other resources straight to your inbox every two weeks.

RSS Feed of the Mendix Blog
Daniela Field

About Daniela Field

Daniela has 7+ years of experience as a technology professional. She enjoys working with clients, understanding their business needs and offering solutions that move clients towards efficiency, productivity and profitability. She has worked with various Fortune 500 companies as well as privately held organizations. Her previous work was focused on enterprise data search, eDiscovery, document assembly and contract management. Currently, she is a Senior Solutions Consultant for the Mendix's Boston office. Daniela firmly believes that the use of Agile methodologies is the future in application development and enjoys the flexibility and speed with which applications can be developed and deployed using the Mendix Platform.

| Twitter