首页 \ 问答 \ 用于创建“值对象”(VO)对象的内部类(Inner Class to Create a “value object” (VO) Object)

用于创建“值对象”(VO)对象的内部类(Inner Class to Create a “value object” (VO) Object)

将内部类用作VO是不好的做法,因此代码可以清晰

EX:在将数据存储到文件中之前,我必须修改一些值。 我创建了一个VO类,以便将来需要修改它时,它可以很容易读取。

此操作过程将仅在此类中执行,并且我生成的VO将不会在任何其他位置使用。 那么在这种情况下创建内部类并使用它更好吗? 做那样的事情是不好的做法? 会创建内部类并将它们用作VO引起任何安全问题吗?


is it a bad practice to use a inner class as a VO so the code can be clear

EX: I have to modify some values before storing the data in a file. I have created a VO Class so that If someone else needs to modify it in future , it could be easily readable.

This process of operation will be performed only in this class and the VO that I generated will not be used in any place else. So In that case is it better to create a inner Class and use it ? would it be bad practice to do something like that ? would creating inner class and using them as VO cause any security concerns ?


原文:https://stackoverflow.com/questions/43541492
更新时间:2023-03-02 07:03

最满意答案

我正在使用Rails 3.2,所以我无法使用Active Job。 我用Sidekiq并且工作正常。 在这里查看非常有用的教程


I am using Rails 3.2, so I couldn't use Active Job. I used Sidekiq and worked fine. Check a very helpful tutorial here

相关问答

更多
  • 嗨你可以编写你的任务,然后写一个新的,它将调用两个单独的任务 - 运行测试和你的task :run_all => ['db:test:clone ', 'db:test:prepare ', 'test:units', :your_task]类似task :run_all => ['db:test:clone ', 'db:test:prepare ', 'test:units', :your_task] Hi You may write your task an then write new one th ...
  • 尝试在代码中设置ENV变量: task :diagram do ENV['filetype']='dot' ENV['disconnected'='true' Rake::Task['erd'].invoke end Try setting the ENV variables in your code: task :diagram do ENV['filetype']='dot' ENV['disconnected'='true' Rake::Task['erd'].invok ...
  • 尝试在schedule.rb中设置环境变量: # config/schedule.rb: set :chronic_options, :hours24 => true set :output, "log/cron_log.log" env :PATH, ENV['PATH'] env :TRELLO_API_KEY, ENV['TRELLO_API_KEY'] env :TRELLO_CLIENT_SECRET, ENV['TRELLO_CLIENT_SECRET'] every 1.minute do ...
  • 该行将puts "I'm in setup"不是任何任务的一部分 - 它将在您正在解析文件时执行您指定的任何任务(甚至是不存在的任务)(严格地说,当Ruby解析文件时不会执行该任务,但是正在执行并设置rake任务): $ rake foo I'm in setup rake aborted! Don't know how to build task 'foo' (See full trace by running task with --trace) 只有在文件被读取后才会执行任务查找,这就是引用的内容 ...
  • 版本0.8的Rake无法处理这个问题,正如其文档中所述(它只是忽略了任何其他参数)。 但是,如果您可以切换到使用Thor ,则可以获得此行为。 要演示, Thorfile使用以下内容创建Thorfile : class VariableArguments < Thor desc 'multiple [ARGS]', "Task with multiple arguments" def multiple(*args) p args end end 然后像这样调用它: $ thor var ...
  • Rake只是ruby代码,所以除非你没有使用某种其他的gem来以某种方式操纵你的简单rake命令。 你不应该加载gemsec文件! 我在github上的rake存储库中搜索了这个$ global变量并没有找到任何结果。 这里 如果您认为自己正在做可能影响自然红宝石代码的事情,请更新问题。 Rake is just ruby code, so unless you are not using some other gem that somehow manipulates your simple rake co ...
  • 我需要在我的rake任务中添加:environment task :my_task => :environment do # do work end 我还添加了followind行: config.dependency_loading = true 在production.rb文件上 I needed to add :environment on my rake task task :my_task => :environment do # do work end i also add th ...
  • 好吧,我决定自己做。 代码不是很漂亮,因为它包含了很多异常处理,但它完成了工作:) require 'rake' require 'net/ftp' def ftp_files(prefixToRemove, sourceFileList, targetDir, hostname, username, password) Net::FTP.open(hostname, username, password) do |ftp| begin puts "Creating dir #{targe ...
  • 我正在使用Rails 3.2,所以我无法使用Active Job。 我用Sidekiq并且工作正常。 在这里查看非常有用的教程 I am using Rails 3.2, so I couldn't use Active Job. I used Sidekiq and worked fine. Check a very helpful tutorial here
  • 使用namespace指令: namespace :db do namespace :seed do task :demo do end end end Use the namespace directive: namespace :db do namespace :seed do task :demo do end end end

相关文章

更多

最新问答

更多
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • 电脑高中毕业学习去哪里培训
  • 电脑系统专业就业状况如何啊?
  • IEnumerable linq表达式(IEnumerable linq expressions)
  • 如何在Spring测试中连接依赖关系(How to wire dependencies in Spring tests)
  • Solr可以在没有Lucene的情况下运行吗?(Can Solr run without Lucene?)
  • 如何保证Task在当前线程上同步运行?(How to guarantee that a Task runs synchronously on the current thread?)
  • 在保持每列的类的同时向数据框添加行(Adding row to data frame while maintaining the class of each column)
  • 的?(The ? marks in emacs/haskell and ghc mode)
  • 一个线程可以调用SuspendThread传递自己的线程ID吗?(Can a thread call SuspendThread passing its own thread ID?)
  • 延迟socket.io响应,并“警告 - websocket连接无效”(Delayed socket.io response, and “warn - websocket connection invalid”)
  • 悬停时的图像转换(Image transition on hover)
  • IIS 7.5仅显示homecontroller(IIS 7.5 only shows homecontroller)
  • 没有JavaScript的复选框“关闭”值(Checkbox 'off' value without JavaScript)
  • java分布式框架有哪些
  • Python:填写表单并点击按钮确认[关闭](Python: fill out a form and confirm with a button click [closed])
  • PHP将文件链接到根文件目录(PHP Linking Files to Root File Directory)
  • 我如何删除ListView中的项目?(How I can remove a item in my ListView?)
  • 您是否必须为TFS(云)中的每个BUG创建一个TASK以跟踪时间?(Do you have to create a TASK for every BUG in TFS (Cloud) to track time?)
  • typoscript TMENU ATagParams小写(typoscript TMENU ATagParams lowercase)
  • 武陟会计培训类的学校哪个好点?
  • 从链接中删除文本修饰(Remove text decoration from links)