首页 \ 问答 \ 继承与构成的区别(Difference between Inheritance and Composition)

继承与构成的区别(Difference between Inheritance and Composition)

组合和继承是一样的吗? 如果我想实现组合模式,那我该如何用Java呢?


Are Composition and Inheritance the same? If I want to implement the composition pattern, how can I do that in Java?


原文:https://stackoverflow.com/questions/2399544
更新时间:2022-11-21 22:11

最满意答案

更新:正如我昨天答应的,我添加了更多链接到列表。

UFFF。 没有多少文档! 最好的建议? 反编译,阅读和调整,看看它是如何做到的,并重新开始循环。 但是你没有要求这个建议,对吧? ;)

现在,还有几个地方会有一点点:

http://androidcracking.blogspot.com/search/label/smali这是最好的一个。 我甚至问这个人一个问题,他回答很快,所以去看看。

http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html非常全面的表 - 很好的参考!

http://webchat.freenode.net/?channels=smali我从来没有尝试过,但它是在baksmali作者的谷歌代码页( http://code.google.com/p/smali/ )

http://forum.xda-developers.com/showthread.php?t=777707最后,这是一段我之前描述的一些关于Captivate相机的黑客的帖子。 你可以在这里跟踪diff,因为我对每个.diff文件做了一些评论。 好的东西从20号的帖子开始。

http://www.slideshare.net/paller/understanding-the-dalvik-bytecode-with-the-dedexer-tool有趣的幻灯片放映有一些基本概念。 好的开始的方式

http://sites.google.com/site/haynesmathew/home/projects/dalvik-notes甚至比典型的.smali更低的水平。 以后参考,但阅读不错。

http://jasmin.sourceforge.net/guide.html Smali语法基于Jasmin,所以这给出了很好的概念。

http://groups.google.com/group/apktool?pli=1有些讨论值得一读。 当你陷入困境的时候,也是一个很好的地方。

最后,但并非最不重要的是我使用的最有用的技巧:在java中开始编写非常基本的类和方法,然后编译它们然后baksmali你自己的代码。 你知道它是做什么的,所以这将会更容易遵循。

祝你好运!


UPDATE: As I promised yesterday, I added some more links to the list.

Ufff. Not much documentation around! Best advice? Decompile, and read, and tweak, and see how it did, and start the cycle again and again. But you did not ask for that advice, right? ;)

Now, there are a few places out there that wil lhelp a little bit:

http://androidcracking.blogspot.com/search/label/smali This is the best one. I even asked the guy a question and he answered very quickly, so go and take a look.

http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html Very comprehensive table - good reference!

http://webchat.freenode.net/?channels=smali I never tried it, but it's on the google code page of the baksmali author ( http://code.google.com/p/smali/ )

http://forum.xda-developers.com/showthread.php?t=777707 Lastly, this is a post I made some time ago describing some hacks to the Captivate camera. You can follow the diffs in there as I comment a little bit on what each .diff file is doing. The good stuff starts at the post #20.

http://www.slideshare.net/paller/understanding-the-dalvik-bytecode-with-the-dedexer-tool Interesting slide show with some basic concepts. Good way to start.

http://sites.google.com/site/haynesmathew/home/projects/dalvik-notes Even more low level than the typical .smali. A reference for later, but a good read.

http://jasmin.sourceforge.net/guide.html Smali syntax is based on Jasmin, so this gives good concepts.

http://groups.google.com/group/apktool?pli=1 Some discussions there are worth reading through. Also a good place to search for when you're stuck in something.

And last, but not least, the most helpful trick I used: start coding very basic classes and methods in java, compile them and then baksmali your own code. You know exactly what it does, so it will be a lot easier to follow.

Good luck!

相关问答

更多
  • 当您创建应用程序代码时,apk文件包含一个.dex文件,其中包含二进制Dalvik字节码。 这是平台实际理解的格式。 但是,读取或修改二进制代码并不容易,所以有工具可以将其转换为人类可读的表示。 最常见的人类可读格式被称为Smali。 这与你提到的拆装工基本相同。 例如,假设你有类似的Java代码 int x = 42 假设这是第一个变量,那么该方法的dex代码很可能包含十六进制序列 13 00 2A 00 如果你运行baksmali,你会得到一个包含该行的文本文件 const/16 v0, 42 这 ...
  • Dalvik将不会处理一些事情,也不会处理与标准Java字节码完全相同的方法,尽管它们大部分都是非常先进的。 最严重的例子是运行时字节码生成和自定义类加载。 假设你想创建一些字节码,然后使用classloader来加载它,如果这个技巧可以在你的普通机器上工作,那么保证在Dalvik上不起作用,除非你改变你的字节码生成。 这阻止你使用某些依赖注入框架,大多数已知的例子是Google Guice(尽管我相信有些人可以这样做)。 另一方面,AspectJ应该使用字节码检测作为编译步骤(尽管我不知道如果有人尝试过) ...
  • 更新:正如我昨天答应的,我添加了更多链接到列表。 UFFF。 没有多少文档! 最好的建议? 反编译,阅读和调整,看看它是如何做到的,并重新开始循环。 但是你没有要求这个建议,对吧? ;) 现在,还有几个地方会有一点点: http://androidcracking.blogspot.com/search/label/smali这是最好的一个。 我甚至问这个人一个问题,他回答很快,所以去看看。 http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html非常 ...
  • 基于堆栈的虚拟机有一些属性与Java的设计目标非常契合: 基于堆栈的设计对目标硬件(寄存器,CPU特性)进行了很少的假设,因此可以在各种硬件上实现虚拟机。 由于指令的操作数很大程度上是隐含的,所以目标代码往往会更小。 如果您要通过缓慢的网络链接下载代码,这很重要。 使用基于注册的方案可能意味着Dalvik的代码生成器不必像制作性能代码一样努力。 运行在非常注册丰富的或注册表不佳的架构可能会妨碍达尔维克,但这不是通常的目标 - ARM是一个非常中等的架构。 我也忘记了Dalvik的初始版本根本不包括JIT。 ...
  • 这是不可能的。 有关详细信息,请参阅YouTube上关于Dalvik内部的Google IO 2008演示文稿。 包括Java和MS .NET的移动虚拟机不是完整的虚拟机,并且由于内存和性能限制,因此省去了允许完成所描述的部分。 its not possible. See the Google IO 2008 presentation on youtube about Dalvik internals for details. Mobile VMs including both Java and MS .N ...
  • 是的,您甚至可以在理论上添加对C#的支持,这意味着您可以添加CLR / CLI支持,或者您喜欢的任何语言或VM。 所有的Android组件都是模块化的,整个操作系统都是可定制的,问题是这需要大量的资金,时间,技术诀窍以及最有可能的专利控制。 点击我的YouTube回复 这是关于Android的官方谈话。 Yes, you can even add a support for C# in theory, meaning that you can add a CLR/CLI support, or whatev ...
  • 你在看什么是davlik字节码。 Java代码由dx工具转换为Dalvik字节码。 清单是一个单独的问题,我将在一分钟内解决。 实际上,当您编译Android应用程序时,dx工具会使用256个dalvik操作码将Java代码转换为字节码(与javac将标准JVM应用程序的Java字节码转换为Java字节码的方式相同)。 例如, invoke-super是一个操作码,它指示dvm(dalvik虚拟机)调用超类的方法。 同样, invoke-interface指示dvm调用接口方法。 所以你可以看到 super ...
  • 如果我已正确理解你的问题:我正在考虑将问题提到的问题为apk(如果是这样,那么以下回答可能有助于ypu) 如果您的目标已连接到主机,则可以使用两种最常用的命令工具: activity manager (am) package manager (pm) 首先通过命令行adb install 例如: adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings将启动设 ...
  • 这给出了dalvik vm中存在的每个操作码的所有细节,并给出了链接1中表中使用的所有指令格式 This gives all the details of each opcode present in the dalvik vm and this gives all the instruction formats used in the table in link 1
  • 我发现问题出在哪里:当打印一个int数字(不是Integer对象)时,参数类型应该是'I'而不是'Java / lang / Integer'。 I found where the problem is : When print an int number (not an Integer object), the parameter type should be 'I' instead of 'Java/lang/Integer'.

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(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?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在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)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)