matlab应用实际应用
by Jake Soenneker
杰克·索纳克(Jake Soenneker)
如何让您的用户实际更新您的应用 (How to get your users to actually update your app)
The software development cycle is accelerating, and the web supports it beautifully. There’s no need to send new binaries to your users. They just visit your site and presto — they instantly have the latest and greatest version of your code.
软件开发周期正在加速,并且网络为其提供了精美的支持。 无需将新的二进制文件发送给您的用户。 他们只是访问您的网站而已-他们立即获得了最新,最出色的代码版本。
But there are situations where your app can’t be served over the web. And sometimes your users need your app to run even when they don’t have internet access. And let’s face it — in 2017 there are still a lot of apps that are too resource-intensive to run in a browser. So desktop applications aren’t going anywhere.
但是在某些情况下,您的应用程序无法通过网络提供。 有时,即使用户无法访问互联网,他们也需要您的应用程序才能运行。 让我们面对现实吧–在2017年,仍然有很多应用程序过于资源密集而无法在浏览器中运行。 因此,桌面应用程序无处不在。
This said, desktop app users still want to be “on edge” with your latest version. They want to be using that cool new feature they read about on your development blog.
这就是说,桌面应用程序用户仍然希望与您的最新版本保持同步。 他们希望使用您在开发博客上阅读的超酷新功能。
“No problem,” the developer says. “I’ll Compile the code, insert the binaries into the installer, and publish a new version to my site. Then users can download my latest version. I’ll just tweet out a link, or include it in next week’s email blast to let them know.”
“没问题,”开发人员说。 “我将编译代码,将二进制文件插入安装程序,然后将新版本发布到我的站点。 然后用户可以下载我的最新版本。 我将发布一条链接,或者将其包含在下周的电子邮件爆炸中,以告知他们。”
This is the traditional way to go about updating a client. And it’s OK for 98% of native desktop applications. It’s business-as-usual for your users. It’s error resistant, and doesn’t require a whole lot of work from developers. Developers can even put a “check for updates” item in their context menus. Your app can ping your website for a latest version number, then redirect your users to the file.
这是更新客户端的传统方法。 而且对于98%的本机桌面应用程序也可以。 对您的用户来说,它是日常事务。 它具有抗错误功能,不需要开发人员进行大量工作。 开发人员甚至可以在上下文菜单中放置“检查更新”项。 您的应用可以ping您的网站以获取最新版本号,然后将您的用户重定向到该文件。
Well, it’s become clear that this traditional way isn’t good enough. Here’s why:
好吧,很明显,这种传统方式还不够好。 原因如下:
- Announcements are critical for getting users on your next version. 公告对于使用户使用您的下一版本至关重要。
- If your app accesses network services, developers need to make them backward compatible. 如果您的应用访问网络服务,则开发人员需要使它们向后兼容。
- Users have to manually update the software. This is means time, energy, and focus lost. 用户必须手动更新软件。 这意味着失去了时间,精力和精力。
- Customer support doesn’t want to address issues with outdated versions. 客户支持不想解决版本过旧的问题。
- Users often retrieve their software other than from the source. It takes time for a new version to propagate, and it will never be up-to-date everywhere. 用户通常从源头以外的地方检索其软件。 新版本的传播需要时间,并且永远不会在任何地方都保持最新。
- For some apps and games, it’s critical that every user runs the exact same version. 对于某些应用和游戏,至关重要的是每个用户都必须运行完全相同的版本。
Automatic updating is hard. Companies feel the burn all the time when something goes wrong.
自动更新很难。 出问题时,公司始终会感到烧伤。
For example, as a user, I don’t know what Slack is doing when it’s updating. All I know is that when it finishes, it often tells me that it’s still not up to date. Chrome fails all the time and doesn’t even tell me why. Windows Update is getting better.
例如,作为用户,我不知道Slack在更新时在做什么。 我所知道的是,完成时通常会告诉我它仍不是最新的。 Chrome浏览器一直失败,甚至没有告诉我原因。 Windows Update越来越好。
Well, as a developer, I have sympathy for the products and the teams who maintain them, because there are many reasons why updates are so difficult.
好吧,作为一名开发人员,我对产品和维护它们的团队表示同情,因为有很多原因使更新如此困难。
- Users run a massive array of operating systems and environment combinations these days. 如今,用户运行着各种各样的操作系统和环境组合。
- The underlying frameworks may need to be updated from one version to the next, too. 基础框架也可能需要从一个版本更新到另一个版本。
- Users continue to tweak security and permissions. 用户继续调整安全性和权限。
- Users may neglect to install updates to their operating system or to your application itself. 用户可能会忽略将更新安装到其操作系统或应用程序本身。
- What if the update system itself needs updating? 如果更新系统本身需要更新怎么办?
- With deploys getting more automated, and with teams shipping code faster, bugs and security issues evolve faster as well. 随着部署变得更加自动化,团队的代码发布速度更快,错误和安全性问题也随之发展。
更多的应用程序需要更好的更新系统。 (More applications need better update systems.)
These update systems add enormous value by giving users the best experience your organization has to offer.
这些更新系统通过为用户提供组织必须提供的最佳体验来增加巨大的价值。
There are oodles of update frameworks available. One popular framework is Squirrel.
有大量的更新框架可用。 一种流行的框架是Squirrel 。
If you’re grappling with update issues, I would urge you to do your homework before recommending anything to your team. It’s worth noting that a large percentage of the existing systems in production today are custom-built. This is because these systems gives developers the most control to their code.
如果您正在处理更新问题,我敦促您先做功课,再向团队推荐任何东西。 值得注意的是,当今生产中的大部分现有系统都是定制的。 这是因为这些系统为开发人员提供了对其代码的最大控制权。
智能灵活的更新系统具有以下功能: (There are several features to an intelligent and flexible update system:)
- The ability to download “deltas” — the differences between the current installation and the new. There’s no need to download a file if the user already has it. 下载“增量”的能力-当前安装和新安装之间的差异。 如果用户已经拥有文件,则无需下载它。
- The system can update and repair itself, and it can recover from issues as they arise. 该系统可以自我更新和修复,并且可以从出现的问题中恢复。
- The system can detect existing frameworks on the operating system. It can download and install new frameworks without the user having to fetch them themselves. 系统可以检测操作系统上的现有框架。 它可以下载和安装新框架,而无需用户自己获取它们。
Some architectures depend on services. I’m looking at you, Google and Adobe. Well, developers shouldn’t rely on these resource-intensive always-running background processes if they can avoid them.
一些架构依赖于服务。 我在看着你,谷歌和Adobe。 好吧,如果开发人员可以避免使用这些资源密集的,始终运行的后台进程,则不要依赖它们。
The architecture I’m going to describe is only one type, but most of them are a variation and follow the same general principles. Going forward, I’ll be more Windows-specific, but these fundamentals apply to other operating systems, too. I’ll cover the basic concepts behind the update system’s components.
我将要描述的体系结构只是一种类型,但是其中大多数是一种变体,并且遵循相同的一般原理。 展望未来,我将更多地针对Windows,但是这些基础知识也适用于其他操作系统。 我将介绍更新系统组件背后的基本概念。
安装程序 (The Installer)
This is the initial entry point for the user, and it’s where the whole process begins. This isn’t a typical ClickOnce or Wix instalIer. It’s a single executable. It does several important things, and it may come as a surprise that it doesn’t contain the main application. What does it do then?
这是用户的初始入口点,也是整个过程的起点。 这不是典型的ClickOnce或Wix安装程序。 这是一个可执行文件。 它做了几件重要的事情,并且其中不包含主应用程序可能会令人惊讶。 那怎么办呢?
- First it checks for OS compatibility. Will this computer be able to run the application at all? 首先,它检查操作系统兼容性。 这台计算机完全可以运行该应用程序吗?
- It has a very low framework requirement. For example, on Windows this would be .NET 2.0 or 3.0. This means users can open the installer with ease if they’re behind on updates. 它具有非常低的框架要求。 例如,在Windows上,它将是.NET 2.0或3.0。 这意味着,如果用户落后于更新,则可以轻松打开安装程序。
- The Installer’s executable has the Updater embedded inside it. Not including the target application makes the executable small in file size. This is great for distribution. The less time there is between the moment the user clicked the download button and the moment they open the installer, the better. 安装程序的可执行文件中嵌入了更新程序。 不包括目标应用程序使可执行文件的文件大小较小。 这非常适合分发。 从用户单击下载按钮到打开安装程序之间的时间越短,效果越好。
- The Installer downloads and installs any necessary frameworks for the Updater. This means going out to Microsoft’s site, retrieving the .NET installer, and using silent parameters to install it. 安装程序将下载并安装更新程序的所有必要框架。 这意味着要访问Microsoft的站点,检索.NET安装程序,并使用静默参数进行安装。
- It creates the initial directories where the entire application environment will stay. Where is that exactly? On Windows, it’s: 它创建整个应用程序环境将保留的初始目录。 那到底在哪里? 在Windows上,它是:
C:\Users\<Username>\AppData\Local\
Why? You don’t need Administrator privileges to install there. This in turn makes the user experience even better, and allows users that don’t have privileges to still use your software. Unless there’s an excellent reason for doing so, don’t prompt the UAC and require privilege escalation.
为什么? 您不需要管理员权限即可在此处安装。 这反过来使用户体验更好,并允许没有特权的用户仍然使用您的软件。 除非有很好的理由,否则不要提示UAC并要求特权升级。
6. The Updater is extracted into AppData and if shortcuts need creating, they will point to the Updater.
6.将更新程序提取到AppData中,如果需要创建快捷方式,它们将指向更新程序。
7. Once that’s done, it starts the Updater.
7.完成后,将启动更新程序。
更新器 (The Updater)
The Updater is the most important part of the entire system, hence the name. It serves as a hub for the rest of the update system.
Updater是整个系统中最重要的部分,因此而得名。 它充当其余更新系统的枢纽。
- First, the Updater takes inventory of the files residing in the folder where it lives. It hashes (MD5, SHA, etc.) each of the files, and stores the values in a dictionary. 首先,更新程序清点驻留在其所在文件夹中的文件。 它对每个文件进行哈希处理(MD5,SHA等),并将值存储在字典中。
- The Updater will send the current framework version it’s dependent on to the Update Server. This is so the Update Server can instruct the Updater to grab a new framework version if it’s needed. Updater会将其依赖的当前框架版本发送到Update Server。 这样,更新服务器可以指示更新程序在需要时获取新的框架版本。
- The Updater will send the dictionary of files/hashes, and the Update Server will determine if the user needs an update. If it doesn’t, the client can move on to the Application. 更新程序将发送文件/哈希字典,更新服务器将确定用户是否需要更新。 如果没有,客户端可以继续到应用程序。
If there is an update available, the Updater will download a compressed file from the Update Server. It will extract the contents in a new folder. If this is the first time the user has opened the Updater, they will receive a package that contains the Application. If the user has downloaded an older installer, this method ensures that there’s no need to download the application twice.
如果有可用的更新,则更新程序将从更新服务器下载压缩文件。 它将内容提取到新文件夹中。 如果这是用户第一次打开更新程序,则他们将收到一个包含应用程序的程序包。 如果用户下载了较旧的安装程序,则此方法可确保无需两次下载应用程序。
- The Updater starts the Extractor. 更新程序启动提取程序。
提取器 (The Extractor)
The point of the Extractor is so that the Updater itself can update. The Extractor doesn’t even need an interface.
提取器的作用是使更新程序本身可以更新。 提取器甚至不需要接口。
- The Extractor performs any cleanup necessary. 提取程序执行所有必要的清理。
- It moves the files from the extracted contents folder back into where the Application lives. 它将文件从提取的内容文件夹移回应用程序所在的位置。
- The Extractor starts the Updater. 提取程序启动更新程序。
更新服务器 (The Update Server)
Why not host the binaries on a web server instead of building a dedicated update server application? Well it’s not possible to do things like client framework checking with a web server, and it won’t be able to build delta update packages. It also helps with things like determining if a repair is necessary or not. There can also be unique version migration situations that may need handling.
为什么不将二进制文件托管在Web服务器上,而不是构建专用的更新服务器应用程序? 嗯,不可能通过Web服务器执行诸如客户端框架检查之类的事情,并且它将无法构建增量更新程序包。 它还可以帮助您确定是否需要维修。 也可能存在需要处理的独特版本迁移情况。
- On the server, all of the components of the update system live in a folder it has access to. When it starts, it builds it’s own hash dictionary of each of these files. 在服务器上,更新系统的所有组件都位于其有权访问的文件夹中。 启动时,它将为每个文件构建自己的哈希字典。
- The necessary dependent framework version is set as a configuration setting on the Update Server. If the message sent from the Updater is less than the version, it will instruct the Updater to download and install the new framework. 必需的从属框架版本在更新服务器上设置为配置设置。 如果从更新程序发送的消息小于版本,它将指示更新程序下载并安装新框架。
- When the development team is ready to deploy a new version, they replace the files the Update Server has inventoried. They refresh the hash dictionary. 当开发团队准备部署新版本时,他们将替换Update Server清单中的文件。 他们刷新哈希字典。
- Remember when the Updater sent that hash dictionary? Well the Update Server compares the two dictionaries and determines the client’s outdated files. This is how it builds delta packages. 还记得更新程序何时发送该哈希字典? 那么更新服务器会比较这两个字典,并确定客户端的过时文件。 这就是它构建增量软件包的方式。
- It compresses the package, and the Update Server will send a message for the Updater to begin its download. 它将压缩程序包,并且Update Server将发送一条消息,要求Updater开始下载。
The following is a diagram of the process moving through the update procedure:
下图是整个更新过程的过程图:
最后的话 (Last words)
In this design, the Updater is the entry point to the application. That doesn’t need to be the case though. Some questions to ask when building an update system:
在这种设计中,更新程序是应用程序的入口点。 但这不是必须的。 构建更新系统时要问的一些问题:
- Do you ask if the user wants to update, do you make it required, or do you hide the process? 您问用户是否要更新,是否需要更新或隐藏该过程?
- Does the Updater need to be its own separate component? It may be able to live in the application itself. 更新程序是否需要成为其自己的单独组件? 它可能可以存在于应用程序本身中。
- Is updating necessary before the application begins? Perhaps it can update as the application is running. 在应用程序开始之前是否需要进行更新? 也许可以随着应用程序的运行而更新。
These are types of questions the developer should consider before jumping into a design. Automated application updating is becoming more popular, and for good reason. It’s easier on the user, and it gets the developer’s code into their hands quicker. As an engineer, strive to make your updating process better for you and your users.
这些是开发人员在进入设计之前应考虑的问题类型。 自动化的应用程序更新正变得越来越流行,这是有充分理由的。 它对用户来说更容易,并且可以更快地将开发人员的代码移交给他们。 作为工程师,请努力为您和您的用户改进更新过程。
Thanks for reading!
谢谢阅读!
matlab应用实际应用